找不到请求的URL。 pythonanywhere中的404错误

问题描述 投票:0回答:1

我有Flask应用,我想在pythonanywhere.com中运行。我关注了Link1Link2链接,无法解决问题。我的烧瓶应用程序名称为tourismmining,目录的内容在[

下列出

应用程序结构

我的应用程序的结构如下。

tourismmining
|-> instance
|-> mining
|-> resources
|-> entry.py
|-> installation.txt
|-> License
|-> Procfile
|-> README.rst
|-> requirements.txt

核心应用程序位于目录mining中,并通过以下方式进行构造

mining
|-> config
|-> db
|-> exceptions
|-> files
|-> forms
|-> logs
|-> models
|-> sink
|-> static
|-> templates
|-> __init__.py
|-> main.py
|-> utils.py

所以,仅通过flask本地服务器,我曾经运行以下命令

 cd tourismmining

 python -m mining.main  

下面是输出

enter image description here

[在旅游业中,我写了另一个名为entry.py的文件,它包含


      from mining import app

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

并且我使用以下命令运行文件entry.py

   cd tourismmining

   python entry.py 

enter image description here

现在,将相同的代码上传到pythonanywhere之后,目录结构在下面给出

enter image description here

[设置虚拟环境并尝试了以下配置wsgi文件的两种方法

import sys
path = '/home/s1782662edin/tourismmining'
if path not in sys.path:
   sys.path.insert(0, path)

from mining import app as application
import sys
path = '/home/s1782662edin/tourismmining'
if path not in sys.path:
   sys.path.insert(0, path)

from entry import app as application

然后重新加载网站,没有任何结果。它说

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 pythonanywhere
1个回答
0
投票

请确保您已定义路由,并且从挖掘导入应用程序时运行了用于定义路由的代码。

© www.soinside.com 2019 - 2024. All rights reserved.