Python Forum

Full Version: [Solved] Running Gunicorn with flask....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I try to run Flask with gunicorn Wall

I've created a venv , here the simple structure

Quote:.
├── bin
├── include
├── lib
├── lib64 -> lib
├── __pycache__
├── share
├── Flask_test.py
└── pyvenv.cfg

Running Flask_test.py with the embedded dev. server is running smoothly

#Flask_test.py
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
	return "<p>Hello, <b>World!</b></p>"


if __name__ == "__main__":
	#app.run(host, port, debug, options)
	app.run('127.0.0.1',5000,True)


now with gunicorn...

All around the www I see that I need to create another .py file and call this one that will call Flask_test.py Doh why so many redirection ?

is there a way to launch unicorn with Flask_test.py directly ?

Thanks.

Edit:

With waitress I could launch it like this

Python3.9 Flask_test.py

and in Flask_test.py I would have:
from waitress import serve

#.......

if __name__ == "__main__":
	serve(app, host='127.0.0.1', port=5000, ipv6=False)
so simple...
I found !!!

It was ~simple...

gunicorn -w 6 Flask_test:app

LOL