【发布时间】:2022-01-01 18:33:19
【问题描述】:
我在 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)
执行输出:
* 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/
有什么帮助吗?
【问题讨论】:
-
"但是无法在任何浏览器上使用:localhost:5000 打开服务器"究竟是什么意思?您是否在浏览器中收到错误页面? Javascript 控制台中的任何内容?网络检查员怎么说?您是否尝试过在烧瓶路由中添加打印语句并检查终端以查看请求是否通过?等等等等。
标签: python python-3.x flask