Last active
May 3, 2019 13:12
-
-
Save rudyryk/6125f76e8aa6b8141256b7159e1aedc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Simple server to host static files for development. | |
Installation: | |
python3 -m venv ~/.virtualenvs/simple | |
source ~/.virtualenvs/simple/bin/activate | |
pip install cherrypy | |
python server.py | |
Snippet source: | |
https://gist.github.com/rudyryk/6125f76e8aa6b8141256b7159e1aedc8 | |
No Rights Reserved | |
http://creativecommons.org/publicdomain/zero/1.0/ | |
""" | |
import os | |
import cherrypy | |
ROOT = os.path.abspath(os.path.dirname(__file__)) | |
PATH = os.path.join(ROOT, 'html') | |
class Root(object): | |
pass | |
cherrypy.tree.mount(Root(), '/', config={ | |
'/': { | |
'tools.staticdir.on': True, | |
'tools.staticdir.dir': PATH, | |
'tools.staticdir.index': 'index.html', | |
'tools.expires.on': True, | |
'tools.expires.secs': 1 | |
}, | |
}) | |
if __name__ == '__main__': | |
cherrypy.engine.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment