[英]flask: server can't start on port 5000
我在 Linux 上的 virtualenv 中執行了以下代碼:
# import the Flask class from the flask module
from flask import Flask, render_template
# create the application object
app = Flask(__name__)
# use decorators to link the function to a url
@app.route('/')
def home():
return "Hello, World!" # return a string
# start the server with the 'run()' method
if __name__ == '__main__':
app.run(debug=True)
執行 output:
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
但無法在任何瀏覽器上使用以下命令打開服務器: http://localhost:5000/
有什么幫助嗎?
嘗試127.0.0.1:5000
而不是localhost:5000
如果沒有再次工作,請使用:
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.