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?
Waitress
now provides a simple command line Utility calledwaitress-serve
for running the Flask Application. Please note that this answer is valid for Waitress 1.30. The command line arguments could change in future.If your Flask application is called myapplication and the method which instantiates your application is called create_app, then you can simply use:-
waitress-serve --call "myapplication:create_app"
This command will launch the server listening on port 8080 by default.
If you wish to launch it on port 80 (http), then all you need to do is:
waitress-serve --port=80 --call "myapplication:create_app"
NB: click on the image if it's not very clear.
Waitress serve command line arguments.
Flask 1.0 production deployment tutorial.
Simple example,try it!
I hope it will help you.
app1.py
waitress_server.py
Then run below command
Try using
To be able to use your internal PC (behind the router) you need to forward in the router the externl port 8080 to internal port 8080 and IP address of your server.
In this conditions you can access your server from outside your network using your external IP. That is OK if you have a static IP address allocated by your provider. If not than you can use a free DNS provider (I use DnsExit) which will provide you with a name for your external IP address. This way you can access your server with a name even if the IP address from your service provider changes from time to time.
I realize this question was probably based in a miss-diagnosed firewall or NAT issue, but in case people come here actually wanting to serve a Flask app with waitress on windows properly (as a service), I want to point to my answer here, so that it can be of use and receive some feedback.
You need to forward the port in your router and use your public IP address.