Python Forum
[Solved] Running Gunicorn with flask....
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Running Gunicorn with flask....
#1
Question 
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...
[Image: NfRQr9R.jpg]
Reply
#2
I found !!!

It was ~simple...

gunicorn -w 6 Flask_test:app

LOL
[Image: NfRQr9R.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question running Flask with waitress having web traffic log... SpongeB0B 2 5,788 May-06-2021, 07:07 AM
Last Post: SpongeB0B
Question Flask, send_from_directory not working : solved SpongeB0B 2 7,345 Jan-26-2021, 07:02 AM
Last Post: SpongeB0B
Thumbs Up Flask do not accept sub-folder in Template ?! : Solved SpongeB0B 2 3,336 Jan-15-2021, 08:09 AM
Last Post: ndc85430
  Flask Ubuntu Server Not Running Wheel 0 1,976 Jul-14-2020, 08:12 PM
Last Post: Wheel
  Running Flask web on other IP than 127.0.0.1 popolon59 1 2,092 Mar-29-2020, 10:02 AM
Last Post: Larz60+
  Flask not running python interpreter from virtual env Charles1 1 2,229 Nov-22-2019, 05:09 PM
Last Post: Larz60+
  Running simple flask - getting 404 beginner1 2 5,266 Oct-28-2019, 02:10 PM
Last Post: beginner1
  Running flask run produces error. Charles1 1 4,028 Oct-04-2019, 10:38 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020