简体   繁体   English

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

I'm completely new to Flask. As a beginner I'm trying to print 'Hello World' on a web page.我是 Flask 的新手。作为初学者,我正在尝试在 web 页面上打印“Hello World”。 When run this Flask application, the browser throwing me a 404 error.当运行这个 Flask 应用程序时,浏览器向我抛出404错误。 It says The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.它说The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Here is my __init__.py :这是我的__init__.py

from flask import Flask

app = Flask(__name__)

from app import app

My routes.py file:我的routes.py文件:

from app import app

@app.route('/')
@app.route('/index')
def index():
    return "Hello, World!"

And my microApp.py file:还有我的microApp.py文件:

from app import app

Here is my working directory:这是我的工作目录:

My Project/
  venv/
  app/
    __init__.py
    routes.py
  microApp.py

I set FLASK_APP = microApp.py and tried to run Flask. But the browser is throwing me an error.我设置FLASK_APP = microApp.py并尝试运行 Flask。但是浏览器向我抛出一个错误。

Please anyone help me, I'm a noob.请任何人帮助我,我是菜鸟。 Thanks in advance.提前致谢。

When you are importing app that means your basically importing __init__.py file.当您导入app时,这意味着您基本上导入了__init__.py文件。 The __init__.py files are modules that initialize the packages. __init__.py文件是初始化包的模块。 modules So in your __init__.py file you importing again 'app'. modules所以在你的__init__.py文件中你再次导入'app'。 Here you have to call 'routes'.在这里,您必须调用“路线”。

A server that does print "Hello world":打印“Hello world”的服务器:

from flask import Flask 

app = Flask(__name__)

@app.route("/")
@app.route('/index')
def hello_world():
    return "Hello world!"

app.run('127.0.0.1', port=5500)

I got here trying to solve an error on a more complex page, involving chartjs.我来到这里试图解决涉及chartjs的更复杂页面上的错误。

What solved to me was sending back to an older library:对我来说解决的是发回一个旧图书馆:

Instead of: https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js' Solved with: https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js'而不是: https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js'解决了: https://cdnjs.cloudflare.com/ajax/libs/Chart。 js/1.0.2/Chart.min.js'

Newer library did not support the type of graph that I wanted.较新的库不支持我想要的图形类型。

暂无
暂无

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

相关问题 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 应用程序 - 错误 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 Flask: Not Found 在服务器上找不到请求的 URL。 如果您手动输入了 URL,请检查您的拼写并重试 - Flask: 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 错误:'在服务器上找不到请求的 URL。 如果您手动输入了 URL,请检查您的拼写并重试。 - python flask URL error: 'The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.' 在服务器上找不到请求的 URL。 如果您手动输入了 URL,请检查您的拼写并重试。 404 - The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. 404 Flask 错误:在服务器上找不到请求的 URL。 如果您手动输入 URL 请检查您的拼写并重试 - Flask error: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again Python Flask API:在服务器上找不到请求的 ZE6B391A8D2C4D45902A23A8B6587。 如果您手动输入 URL 请检查您的拼写并重试 - Python Flask API : The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again 为什么我会收到“在服务器上找不到请求的 URL。如果您手动输入了 URL,请检查您的拼写并重试” - Why am I getting "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again" Flask:404 在服务器上找不到请求的 URL。 - Flask: 404 The requested URL was not found on the server. 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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM