我正在尝试使用swagger作为查询我的烧瓶应用程序的前端。我正在使用弗拉斯格,我尝试了一个玩具示例,如下所示
from flasgger import Swagger
from flask import Flask, logging
app = Flask(__name__)
Swagger(app)
# ENDPOINT = 1
@app.route('/hello',methods=['GET'])
def helloapp():
return 'Hello World'
if __name__ == '__main__':
app.run(debug=True,threaded=True,port=7005)
file_handler = logging.FileHandler('app.log')
app.logger.addHandler(file_handler)
app.logger.setLevel(logging.INFO)当我试图查询端点http://localhost:7005/hello时。我得到了“你好世界”的结果。
如果我试图查询http://localhost:7005/apidocs/,这将显示基本的UI

但是,当我试图查询端点根时。招摇过市的UI没有出现。它会抛出一个404错误
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.对于这个问题有什么建议吗?
发布于 2019-04-09 16:15:32
尝试将端点根添加到您的路由,如下所示:
@app.route('/')
@app.route('/hello',methods=['GET'])
# ... 因为您没有将它定义为路由,所以在服务器上找不到它。我希望这能帮到你
https://stackoverflow.com/questions/48680405
复制相似问题