Created
April 17, 2021 13:12
-
-
Save vmleon/165dd63fcf276bde07204a29b39a565d to your computer and use it in GitHub Desktop.
Flask Cheroot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install cherrypy | |
nohup python server.py 2>&1 > app.log & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): | |
return 'Hello, World!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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