User Manual
55
Server Code
The server code is based on Django 1.10 (adapt to the latest release if needed). If you are
interested in this, you can visit the Django website https://www.djangoproject.com/, or read
The Django Book to learn more at http://gsl.mit.edu/media/programs/south-africa-summer-
2015/materials/djangobook.pdf. Here we will just learn how the web server works. Note: The
code may be updated irregularly on Github to fix bugs and release some functions update.
So the code here is the initial version. You can view the updates in the Github repository at:
https://github.com/sunfounder/SunFounder_PiCar-V.
Open the code directory and check the file by ls:
pi@raspberry:~ $ cd SunFounder_PiCar-V/
pi@raspberry:~/SunFounder_PiCar-V $ ls
datasheet install_dependencies mjpg-streamer remote_control
client i2cHelper.py LICENSE README.md show
remote_control is the main code directory of the web server. Open the code directory by
cd remote_control, and check the file by ls:
pi@raspberry:~/SunFounder_PiCar-V $ cd remote_control
pi@raspberry:~/SunFounder_PiCar-V/remote_control $ ls
db.sqlite3 manage.py remote_control start static
db.sqlite3 is generated when you create a Django project.
manage.py is the main program of the Django project and is generated when the project is
created. It normally does not need to be modified.
remote_control includes the main code files.
start is a small script written to run sudo python manage.py runserver 0.0.0.0:8000, and
servo installation with attribute install just for convenience.
static is to store some static pictures on the web.
The Django web server normally runs sudo python manage.py runserver to start. The address
0.0.0.0:8000 means the listening address covers all the addresses on the LAN, and the port
number is 8000. Here we will just focus on the code in remote_control folder. Go to the
directory via cd remote_control:
pi@raspberry:~/SunFounder_PiCar-V/remote_control $ cd remote_control
pi@raspberry:~/SunFounder_PiCar-V/remote_control/remote_control $ ls
driver __init__.py settings.py templates urls.py views.py wsgi.py
driver stores the drivers of the car.
__init__.py is automatically generated when you create a Django project which is a
standard necessary document of python package, just leave it there.
settings.py is automatically generated and stores the related settings.