How to use cherrypy as a web server for static files?
This simple code will serve files on current directory.
import os
import cherrypy
PATH = os.path.abspath(os.path.dirname(__file__))
class Root(object): pass
cherrypy.tree.mount(Root(), '/', config={
'/': {
'tools.staticdir.on': True,
'tools.staticdir.dir': PATH,
'tools.staticdir.index': 'index.html',
},
})
cherrypy.quickstart()
Here is some information on serving static content with CherryPy: http://docs.cherrypy.org/stable/progguide/files/static.html
BTW, here is a simple way to share the current directory over HTTP with python:
# Python 3 $ python -m http.server [port] # Python 2 $ python -m SimpleHTTPServer [port]