Serving Flask app with waitress on windows

llulai picture llulai · Jun 26, 2018 · Viewed 31.8k times · Source

I am able to run a webserver using the following code

from flask import Flask
from waitress import serve

app = Flask(__name__, static_url_path='/static')
...
serve(app, port=8080)

The problem is that I can access it only from the machine where it is running, if I try to access it using the ipv4 ip, it doesn't work. Am I missing a step?

Answer

Dondon Jie picture Dondon Jie · Aug 30, 2018

Simple example,try it!
I hope it will help you.

app1.py

from flask import Flask
app = Flask(__name__)
# app.run(host='0.0.0.0', port=8080,debug=True)

waitress_server.py

from waitress import serve
import app1
serve(app1.app, host='0.0.0.0', port=8080)

Then run below command

python waitress_server.py