https://github.com/javascriptdude/flask_restx_shutdown
Sample of Building Flask_restx Server with test Browser and Closing From Resource
https://github.com/javascriptdude/flask_restx_shutdown
Last synced: about 1 month ago
JSON representation
Sample of Building Flask_restx Server with test Browser and Closing From Resource
- Host: GitHub
- URL: https://github.com/javascriptdude/flask_restx_shutdown
- Owner: JavaScriptDude
- License: mit
- Created: 2021-10-03T22:37:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-03T22:58:38.000Z (over 3 years ago)
- Last Synced: 2025-02-12T07:54:36.682Z (3 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask_restx_Shutdown
Sample of Building [flask_restx](https://flask-restx.readthedocs.io/en/latest/) Server with test Browser and Closing From ResourceThere are some edge cases where the web server needs to be shut down by the request handler in a Flask application.
This sample uses [flask_restx](https://flask-restx.readthedocs.io/en/latest/) and passes a shutdown method to selected Resource to allow it to shut down the web server. This example launches a Web Server and a web browser and will automatically close the web server and/or browser if the user presses a button or closes the web browser.
It may seem contrived but this is a good example of where some testing can be done which requires user interaction and a web browser session.
This sample can be seen as a possible workaround for the deprecation of [`werkzeug.server.shutdown`](https://github.com/pallets/werkzeug/issues/1752) although, this does require running all resources through [flask_restx](https://flask-restx.readthedocs.io/en/latest/) .
To run:
```python3 sample.py```This code was written to run on Linux. Should work ok on MacOS and although not tested, it will likely not work on windows.