Skip to content

Instantly share code, notes, and snippets.

@cdent
Last active December 17, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdent/5564147 to your computer and use it in GitHub Desktop.
Save cdent/5564147 to your computer and use it in GitHub Desktop.
Quick and dirty wsgiref server for use with [tsapp](http://tsapp.tiddlyspace.com) as an example of using a different server than the built in cherrypy server. This one is likely to be quite slow due to its single process/thread nature. To use set `wsgi_server: wsgirefserver` in `.tsapp`.
import sys
from tsapp.proxy import create_app
from wsgiref.simple_server import make_server
def start_server(config):
port = int(config['port'])
local_host = config['local_host']
httpd = make_server(local_host, port, create_app(config))
try:
httpd.server_forever()
except KeyboardInterrupt:
sys.exit(0)
@pads
Copy link

pads commented Jul 29, 2014

There is a typo on line 14 - it should be httpd.serve_forever()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment