'Python-Flask, Server generated from swagger file produces 'do some magic!' for all get methods
I have generated Python Flask-Server API from swagger editor: https://editor.swagger.io/
When I run the server locally, I noticed that all my get methods produce the same output:
'do some magic!'
I have replaced that phrase in all my controllers methods, and restarted the server. But it still generates that stupid output instead of the expected ones. Where does it come from?

Here is the way to reproduce the problem:
- go to https://editor.swagger.io/ and create simple interface with one method
- generate server code python-flask
- open it in IDE (I am using VS Code on Windows), go to controllers, update return of you methos, and run ./swagger_server/main.py
- when the server is ready to respond, call that method (http://localhost:8080/yourmethod) and you will notice that it always returns 'do some magic!' regardless of what your controller contains
def module_health_check(): # noqa: E501
return 'do another magic!'
But if you build Docker and run it as a container, it will call your controller properly as expected. I think something wrong with my dev environment settings in Windows Visual Studio Code, which generates stub result in run time (without docker)
Solution 1:[1]
Ok, I think I have found a solution shortly described here https://code.visualstudio.com/docs/python/tutorial-flask It seems like my VS Code IDE behaves differently:
- when you run _ _ main _ _.py (or app.py - default for Flask) directly, it generates that stupid message for ALL methods
- and it works correctly, when you run it as described in that doco: python -m swagger_server
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ban |
