I'm moving my code from Flask to Falcon and a small annoyance is that I can't seem to find way to run my Falcon-based app from the __main__
method. In my Flask app I had this:
if __name__ == '__main__':
app.run(port=os.getenv('PORT', 5000))
Is there a way to do the same for the Falcon app? I don't mind to use a wrapper like Gunicorn but that one also seems to not run (easily) from the __main__
as well
Note: This is strictly for development purposes, I know how to run the Falcon app in production
Sure use wsgiref
, e.g.:
from wsgiref import simple_server
if __name__ == '__main__':
with simple_server.make_server('', os.getenv('PORT', 5000), app) as httpd:
httpd.serve_forever()