简体   繁体   中英

The Requested url not found. 404 error in pythonanywhere

I have Flask app, and I wanted to run in pythonanywhere.com. I have followed the links Link1 , Link2 , couldn't resolve the issue. My flask app name is tourismmining and the contents of the directory is listed under

Application Structure

My application is structured in the below way.

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

The core application is in the directory mining and is structured in the following way

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

So, just by flask local server, I used to run the below command

 cd tourismmining

 python -m mining.main  

and below is the output

在此处输入图片说明

In touristmining, I have written an another file named entry.py, and it contains


      from mining import app

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

And I run the file entry.py using the below command

   cd tourismmining

   python entry.py 

在此处输入图片说明

Now, after uploading the same code in to pythonanywhere, the directory structure is given below

在此处输入图片说明

Setting up the virtual environment and tried two ways of configuring the wsgi file which are given below

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

And reload the website, nothing worked out. Its says

Not Found
The requested URL was not found on the server. If you entered the URL manually please check your 
spelling and try again.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM