from flask import Flask
app = Flask(__name__)
@app.route('/hello')
def hello_world():
return "Hello world"
if __name__ == '__main__':
app.run(host='0.0.0.0',port=8000, debug=True)
单击 http://0.0.0.0:8000/链接时,它显示:
> The requested URL was not found on the server If you entered the URL
> manually please check your spelling and try again.
您定义的唯一URL是/hello
,因此当您请求/
时,没有任何要提供的服务,因此您会收到Not Found
错误。您需要为/
定义一些内容或改用http://0.0.0.0:8000/hello
。例如,
@app.route('/')
def index_view():
return "hello from index"