I wrote a small Python script which should act as webserver based on Flask.
But I cant reach the server, although I am quit sure the server is up.
Is there some kind of firewall which I have to config that I can reach the Webpage from another Computer? Or might it be that lighttpd is blocking my flaskserver? How can I test if the lighttpd server is runing?
Kind regards.
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Test"
if __name__ == "__main__":
app.run(debug=True)
many thanks for your message. If you have lighttpd, it will prevent other web server to start. Because, port 80 (http) can be used once only per server. It’s not possible to have 2 web server running on same port. You would need to configure one web server to LISTEN on another port.
To check which port are in use, you can run following.
Hi,
thank you. I think lighttpd is not running. That was not the problem.
Yesterday I had the same config on Raspbian. It worked without a problem. I could reach the server under 192.168.178.52. But DietPi …?
The Flask-Server is running under ‘127.0.0.1:5000’. I dont know, where to change this into :80 or even 192.168.178.52:80.
Is it imporatant to change it to :80?
…
Find the answer meanwhile:
Yes it is. I solved the problem thanks to duckduckgo.com. I had to ad the IP and Port in the script as follows. Thanks to you all. And sorry for bothering you. I just starting into pyhton and coding.
from flask import Flask
app = Flask(__name__)
@app.route('/')
@app.route('/home')
def index():
return "Test"
if __name__ == "__main__":
app.run(debug=True, host='192.168.178.52', port=80)
you have now restricted your web server to LISTEN on IP address 192.168.178.52 only. This might not be that flexible. You could try using 0.0.0.0 instead. This should allow your web server to listen on ALL interfaces and IP address. In case you change it, you don’t need to reconfigure your script.