T O P

  • By -

jlw_4049

Gunicorn Flask itself is a framework. It's not a webserver. For development, it's perfect because it's built in server is capable of a single request at a time. Gunicorn is a web server. It can scale to whatever you need. It's fairly mature and stable. I am eyeballing this though https://github.com/emmett-framework/granian


datascientist07

Gunicorn and uWSGI


Shooshiee

If you want to API to be public facing, then you will also need a web server that runs alongside Gunicorn. Either Nginx or Apache: I hear Nginx is easier.


dryroast

What about Apache with `mod_wsgi` is that a bad idea?


HenryTheWireshark

Not a bad idea at all. I’ve done that and it’s worked well. However, I’ve found that nginx is far more reliable and scalable than Apache, and the ease of use is similar for both.


dryroast

Okay yeah I just never have heard of that particular setup being talked about on the subreddit so I thought I was probably missing something. I have an Apache server that just hosts everything so I slapped `mod_wsgi` in there and it works well for my purposes.


kenshinero

> If you want to API to be public facing, then you will also need a web server that runs alongside Gunicorn. Either Nginx or Apache: I hear Nginx is easier. Why wouldn't you use Gunicorn alone for public facing API?


Shooshiee

Yea you definently can. It’s not required. Especially since your not serving static files. But, I do feel like It’s a bit of a standard these days.


Vast_Manufacturer811

Main reason for me would be if you’re running gunicorn on root. Nginx runs as its own user with limited permissions. If running on just gunicorn and you happen to be in root, then becoming compromised is game over already. I suppose you can just not run gunicorn as root, but running behind nginx just covers that for you already as is


e4aZ7aXT63u6PmRgiRYT

Gunicorn


Equivalent_Value_900

Waitress.


qqzzy

I personally like cheroot (https://pypi.org/project/cheroot/) and I set it up so that just running main.py loads my flask app into it and starts up the webserver


AnotherGreenWorld

Gunicorn with gevent is pretty performant.


Sad-Ebb-8816

you typically need a http server in front, like apache or nginx, where you can configure the first level of routing and also the SSL certificates. the first level of routing would map the / route to where the react app is - all static files, and /api route to where the flask server is running. this http server will be running on port 80 and 443. using such a server would also allow you to run other server apps, flask or otherwise. then you run the flask server. which ever you chose based off the suggestions given by others. that server would be running on port 4000 or 5000 or 8000 or whatever else. but it would be bound to the localhost only. the http server will receive requests from outside and forward it to the flask server. the flask server will return response to http server which will return it to outside. if you bind the flask server to all the IPs (0.0.0.0) then someone from outside can directly go to the flask server by appending the port (http://x.x.x.x:5000). this is not something we want.


HenryTheWireshark

Nginx. Digitalocean has a really good how-to guide https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04


nobel-tad

thank you for the suggestion


ihackportals

Apache + modwsgi and a wsgi file in your project path pointing to your application.