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()
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()