【问题标题】:The Requested url not found. 404 error in pythonanywhere未找到请求的 URL。 pythonanywhere中的404错误
【发布时间】:2020-01-04 04:34:05
【问题描述】:

我有 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

所以,只是通过烧瓶本地服务器,我曾经运行以下命令

 cd tourismmining

 python -m mining.main  

下面是输出

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


      from mining import app

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

然后我使用以下命令运行文件entry.py

   cd tourismmining

   python entry.py 

现在,将相同的代码上传到pythonanywhere后,目录结构如下所示

设置虚拟环境并尝试了两种配置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】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-05
      • 1970-01-01
      • 2014-01-06
      • 2013-10-24
      • 2021-09-30
      • 2015-07-14
      相关资源
      最近更新 更多