简体   繁体   English

Flask:404 在服务器上找不到请求的 URL。

[英]Flask: 404 The requested URL was not found on the server.

I am trying to run the portion of the code with Curl and Flask.我正在尝试使用 Curl 和 Flask 运行该部分代码。 But I a getting the 404 error.但是我收到了 404 错误。 I am pretty sure I am writing the code right as well.我很确定我也在正确地编写代码。 But it's giving me the error.但它给了我错误。

Code:代码:

    @app.route('/todo/api/v1.0/tasks/<int:task_id>', methods=['GET'])
def get_task(task_id):
    task = [task for task in tasks if task['id'] == task_id]
    if len(task) == 0:
        abort(404)
    return jsonify({'task': task[0]})

REQEST: curl -i http://localhost:5000/todo/api/v1.0/tasks/2请求:curl -i http://localhost:5000/todo/api/v1.0/tasks/2

Make sure to check where you app.run is.确保检查您的 app.run 在哪里。 It needs to be in the bottom of the file.它需要位于文件的底部。

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

In Python 3 it's can fix like this for example:在 Python 3 中,它可以像这样修复,例如:

list(filter(lambda t: t['id'] == task_id, tasks))

How to find the length of a "filter" object in python 如何在python中找到“过滤器”对象的长度

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在此服务器上找不到请求的URL /。 Apache服务器中的烧瓶 - The requested URL / was not found on this server. Flask in apache server Flask - 404 未找到:在服务器上未找到请求的 URL。 如果您手动输入 URL,请检查您的拼写并重试 - Flask - 404 Not found : The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again python Flask - 在服务器上找不到请求的 URL。 (但为什么?) - python Flask - The requested URL was not found on the server. (But why?) Flask 应用程序 - 错误 404,在服务器上找不到请求的 URL。 如果您手动输入了 URL,请检查您的拼写并重试 - Flask app - Error 404, The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again Not Found 在服务器上找不到请求的 URL。 如果您输入了 URL... Flask 重定向不起作用 - Not Found The requested URL was not found on the server. If you entered the URL… Flask redirection from not working Flask 上 Ubuntu Apache / 请求错误 404 ZE6B391A8D2C4D45702A23 上未找到此服务器 - Flask on Ubuntu Apache / Error 404 requested URL was not found on this server “在此服务器上找不到请求的URL /。”Heroku / Django - “The requested URL / was not found on this server.” Heroku/Django 在此服务器上找不到请求的URL。 Django的 - The requested URL was not found on this server. Django FLASK - 在服务器上找不到请求的 URL。 如果您手动输入 URL 请检查您的拼写并重试 - FLASK - The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again FLASK - 在服务器上找不到请求的URL - FLASK - the requested url was not found on the server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM