简体   繁体   中英

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

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

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