Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created January 16, 2015 03:13
Show Gist options
  • Save blaquee/0e1ad65aa935320cb8be to your computer and use it in GitHub Desktop.
Save blaquee/0e1ad65aa935320cb8be to your computer and use it in GitHub Desktop.
cherrypi server
import web
from web.wsgiserver import CherryPyWSGIServer
CherryPyWSGIServer.ssl_certificate = "/ssl/server.crt"
CherryPyWSGIServer.ssl_private_key = "/ssl/server.key"
urls = ("/secrets/.*", 'secrets')
app = web.application(urls, globals())
class hello:
def GET(self,name):
ext = name.split(".")[-1] #get extensions
ftypes = { "text":"secrets/txt"}
if name in os.listdir('secrets'):
web.header("Content-type",ftypes[ext])
return open('secrets/%s'%name, "rb").read() #serve the file
else:
raise web.notfound()
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment