Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

Jacopo Scrinzi
Jacopo Scrinzi
16,668 Points

How to deploy a Flask App

Hi there,

I'm building a Flask app and I'd like to deploy it to production server. Here in Treehouse we always run the application via terminal using flask as HTTP server. I did a little but of research and i saw a lot of people using Apache with wsgi module. What is the best way to put my application in production?

Cheers

Edit:

found a working solution. I'm using UWSGI + Virtualenv + NGINX. I have a service that use uwsgi to run the application and creates a socket then I point NGINX to the socket. Here is a guide how to do it: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04

2 Answers

Jacopo Scrinzi
Jacopo Scrinzi
16,668 Points

Heroku is not really what I was looking for. I need to deploy it on an Ubuntu server where I have already other stuff on it. I saw you can use guinicorn and nginx but I was wondering what was the best option. Any tips?

did you ever figure this out? I'm looking for the same thing.

Jacopo Scrinzi
Jacopo Scrinzi
16,668 Points

Yes, found a working solution. I'm using UWSGI + Virtualenv + NGINX. I have a service that use uwsgi to run the application and creates a socket then I point NGINX to the socket. Here is a guide how to do it: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04

igsm '
igsm '
10,440 Points

https://www.youtube.com/watch?v=pmRT8QQLIqk Guy does a good job in 4 minutes to deploy a simple Flask app on Heroku (if you already have an account and venv).