繁体   English   中英

Flask and Swagger UI不起作用?

[英]Flask and Swagger UI does not work?

我正在尝试使用Flask和swagger创建一个RESTful应用程序。 但是,当我运行端点时,我看不到浏览器中记录的方法,例如此处所述,例如http://michal.karzynski.pl/blog/2016/06/19/building-beautiful-restful-apis-using-flask -swagger-ui-flask-restplus /相反,只是404 not found错误。 这是我的代码:

def init_deserializer_restful_api():
    # Get port number for the web app.
    PORT = 8000

    # Initiate the Flask app
    app = Flask(__name__)
    Swagger(app)
    CORS(app)

    # Handler for deserializer
    @app.route("/deserialize", methods=['POST','GET'])
    def handle_deserialization_request():
    # Method description
    # Method content

应用程序是这样运行的:

app.run(port=PORT, host="0.0.0.0")

我运行http://localhost:8000/deserializer我得到The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again

问题:1.如何向烧瓶提供所需的request.json? 2.我如何大张旗鼓地工作?

尝试localhost:8000 / apidocs / index.html

说明-这是Swagger的默认端点。 您试图做的是访问API的一个端点,并期望它呈现Swagger UI。 Swagger UI是API的附加端点,它列出并允许您尝试所有其他端点。 希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM