I made a simple REST API with Python, Flask, Connexion and Swagger. All is working well on my local machine (Windows 10), but not on our server (Debian). I made a mod_wsgi application that is working with Apache2. I can see it is running: if i go to my assigned url <ip>/test. I can see my rendered "Hello World" HTML page.
The reason I use Swagger is that it is easy to explore the API and serves as documentation. However, the actual UI is not loading. When I visit <ip>/test/ui, I can see the Swagger logo, but it is displaying Fetch error, Not Found /openapi.json. I made a screenshot.
This is the code I used as my Python application:
from flask import render_template import connexion # Create the application instance app = connexion.App(__name__, specification_dir='./') # Read the swagger.yml file to configure the endpoints app.add_api('swagger.yml') # Create a URL route in our application for "/" @app.route('/') def home(): """ This function just responds to the browser ULR localhost:5000/ :return: the rendered template 'home.html' """ return render_template('home.html') # If we're running in stand alone mode, run the application if __name__ == '__main__': app.run(debug=True)
In the same folder as the Python and WSGI file is a swagger.yml present. I tried duplicating it to JSON and YAML and changing the `app.add_api` call, but no result. Also tried making a seperate folder for the yml, yaml or JSON file, no result either.