Hi !
I wrote a simple Flask app using flask and sqlalchemy which run pretty well on localhost but I would like to deploy it. The problem is that I don't have any clue on how to deploy it..
Could somebody explain me the simplest way to deploy my Flask app?
Thanks !
EDIT
I'm on Windows
Top comments (10)
Mitch,
Thanks much for posting this detailed guideline. By any chance are you planning to do an updated blog post ? I attempted to follow - your blog post to the very last detail, and could not get the Flask App deployed.
There were a couple of errors specific to apache - and after a LOT of research later, it was just a dead end for me.
Thanks
Sandeep.
I don't think he'll receive a notification since it's not a reply to his comment, let me tag him ! @mitchjacksontech
Sandeep, have you been able to solve the problem? If not and you're interested in revisiting, perhaps I can help with the apache errors. You can find my e-mail address on my dev.to profile
Flask's own documentation give you a few deployment options.
You can try Heroku's free plan:
Getting Started on Heroku with Python: the example in the Heroku doc uses Django but you can get a bit of familiarity with the platform this way
Deploying a Python Flask app on Heroku
I am successfully using the simple Twisted Web server on Windows for Flask web sites.
Are others also successfully using Twisted on Windows, to validate that configuration?
new_app.py
if name == "main":
reactor_args = {}
old_app.py
if name == "main":
app.run()
I had the same problem when I deployed my first Flask app. To approach the problem, I created a very simple small application, and worked through the kinks until I got it deployed in a way I was happy with. Only then did I move to deploying my full application.
I documented the process in this blog post. Perhaps it will be some help.
You will need a WSGI server. Have a look at this tutorial. It shows you how to deploy a flask app using Nginx and uwsgi.
You might also take a look at Netlify. It's a well documented tool for deploying side projects quickly and even beyond:
netlify.com/docs/#python
Here is an article about deploying flask with Waitress.
medium.com/brillio-data-science/ex...
In case you want to deploy Flask app to azure, you can follow along with the tutorial here bit.ly/2lCnxMx