Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
689 views
in Technique[技术] by (71.8m points)

webserver - Trying to make a simple python web server and its not starting

Ive been trying to make a web server and I have the code down that should be able to get it running but when I go in to the Command Prompt and type python app.py it doesn't run when it should this is the code that I have

from flask import Flask
app = Flask(__name__)

@app.route("/")
def main():
    return "Welcome to my Flask page"

if __name__ == "__main__":
    app.run(debug = True, host = "0.0.0.0", port=80)```

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think the problem is port 80. Which OS are you using? Ports under 1024 need root privileges, there is also a possibility that it is not working because some other service (like Apache) is running on this port.

So either fixing privileges or services or changing the port should make it run.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...