User Manual

56
templates is a Django app for storing the webs in the html format.
urls.py is generated automatically to configure the URL to associate with the code.
views.py is the code for page control which is associated by the URL. It calls the templates
to show the page and the driver to control the car.
wsgi.py is generated automatically and does not need changes. For more, please visit the
official website of Django.
So here is how the code works: Run the main program manage.py which will be associated
with urls.py automatically, to respond to the URL. When you run the web browser like the
Chrome to visit http://<rpi_ip_address>:<port> or visit the configured API via the client,
the manage.py will turn to views.py due to the association of the urls.py. Then the views.py
processes this and returns the templates to the browser. In addition, it will call the driver
package on the basis of the parameters set in the browser to control the car.
Now open the folder driver and check:
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control $ cd driver/
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control/driver $ ls
camera.py config __init__.py stream.py
The driver folder mainly includes the driver modules for controlling the pan and tilt and
camera streamer.
camera.py for controlling the pan-and-tilt.
config stores the calibration data.
__init__.py is the essential file of the package and you can just leave it alone.
stream.py is a video streaming service based on the MJPG-streamer.
Exit and open the folder templates to view:
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control/driver $ cd ../
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control $ cd templates/
admin.py __init__.py models.py tests.py
apps.py migrations templates views.py
This folder is created by the manage.py startapp just for calling the templates conveniently.
Therefore, the files have not been changed except for the templates. Open the templates
again:
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control/templates $ cd
templates
pi@raspberry:~/SunFounder_PiCar-
V/remote_control/remote_control/templates/templates $ ls
base.html cali.html run.html