Use this when your Django development server just doesn't cut, and you're too lazy to install XAMPP/Apache.
I wrote this server when I started working with HTML5
So, I wrote this server, and added a URL redirect inside my Django app to serve all video content through CherryPy (instead of Django) ... and VOILA! Everything worked!
-
Install CherryPy:
pip install cherrypy
oreasy_install cherrypy
-
Make sure it's installed:
python -c 'import cherrypy'
-
You can edit the listening URL/port inside the source file.
-
The root directory is the directory where you executed the script.
Just execute the file on your shell/terminal: python cherrypy_static_server.py
"4. The root directory is the directory where you executed the script."
Isn't it actually the directory where the script is located? If it was the directory where you executed the script, I think the code would have to be
os.path.abspath(os.getcwd())
Also, the code can be made slightly simpler: