我每次运行此代码时都会收到404错误

时间:2020-02-02 03:38:06

标签: http-status-code-404

from flask import Flask


app = Flask(__name__)

app.route('/game', methods=['GET'])
def attendance():

    return "hello"


if __name__ == '__main__':
    app.run(debug=True)

1 个答案:

答案 0 :(得分:0)

请参考此内容以最小化烧瓶的应用

https://flask.palletsprojects.com/en/1.1.x/quickstart/#a-minimal-application

您的示例如下所示:

app.py

from flask import Flask
app = Flask(__name__)

@app.route('/game')
def attendance():
    return 'hello'

if __name__ == "__main__":
    app.run(debug=True)

运行app.py(本地),然后在浏览器中以以下方式打开:

http://127.0.0.1:5000/game