James K J
James K J

Reputation: 615

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

enter image description here

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 

enter image description here

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

enter image description here

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.

Upvotes: 0

Views: 896

Answers (1)

Glenn
Glenn

Reputation: 5786

Make sure that you have routes defined and that the code for defining the routes is run when app is imported from mining.

Upvotes: 0

Related Questions