Skip to content

Instantly share code, notes, and snippets.

@Cellebyte
Created January 7, 2020 16:19
Show Gist options
  • Save Cellebyte/e131af3564e322eb6b5613c7733b8d51 to your computer and use it in GitHub Desktop.
Save Cellebyte/e131af3564e322eb6b5613c7733b8d51 to your computer and use it in GitHub Desktop.
Initialization for serving a WSGI app.
try:
from cheroot.wsgi import Server as WSGIServer, PathInfoDispatcher
except ImportError:
from cherrypy.wsgiserver import CherryPyWSGIServer as WSGIServer, WSGIPathInfoDispatcher as PathInfoDispatcher
from .your_module import app
d = PathInfoDispatcher({'/': app})
server = WSGIServer(('0.0.0.0', 5000), d)
if __name__ == '__main__':
try:
server.start()
except KeyboardInterrupt:
server.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment