Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"""
Example app:
from framework import server, add_route
def home():
return "<html>Hello!</html>"
add_route('/', home)
server.serve_forever()
"""
from wsgiref.simple_server import make_server
ROUTES = {}
def add_route(route, func):
ROUTES[route] = func
def my_site(environ, start_response):
start_response("200 OK", [('Content-Type','text/plain')])
return ROUTES[environ["PATH_INFO"]]()
server = make_server('localhost', 8080, my_site)
if __name__ == '__main__':
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment