Skip to content

Instantly share code, notes, and snippets.

@rudyryk
Last active May 3, 2019 13:12
Show Gist options
  • Save rudyryk/6125f76e8aa6b8141256b7159e1aedc8 to your computer and use it in GitHub Desktop.
Save rudyryk/6125f76e8aa6b8141256b7159e1aedc8 to your computer and use it in GitHub Desktop.
"""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