Skip to content

Instantly share code, notes, and snippets.

@vmleon
Created April 17, 2021 13:12
Show Gist options
  • Save vmleon/165dd63fcf276bde07204a29b39a565d to your computer and use it in GitHub Desktop.
Save vmleon/165dd63fcf276bde07204a29b39a565d to your computer and use it in GitHub Desktop.
Flask Cheroot
pip install cherrypy
nohup python server.py 2>&1 > app.log &
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
try:
from cheroot.wsgi import Server as WSGIServer, PathInfoDispatcher
except ImportError:
from cherrypy.wsgiserver import CherryPyWSGIServer as WSGIServer, WSGIPathInfoDispatcher as PathInfoDispatcher
from main 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