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

Issue

I am just a beginner in this api creating with python and I was trying to create an api.

But when I run the code, it gives me the error : 404

init.py

from flask import Flask
from flask_restful import Api

app = Flask(__name__)
api = Api(app)

routes.py

from flask_restful import Resource

from src import api


class Smoke(Resource):
    def get():
        return {'message': 'Ok'}, 200


api.add_resource(Smoke, '/')

wsgi.py

from src import app

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

Solution

The routes.py file is never called, so the route is never bound to the api.
Change your wsgi.py file to:

wsgi.py

from src import app, api
from src import Smoke

if __name__ == '__main__':
    api.add_resource(Smoke, '/')
    app.run()

Answered By – Yuval s

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published