Spaces:
Sleeping
Sleeping
Download scripts/utils/flask_async_fix.py from techprotrade/annator-command-center: direct link, hf CLI and curl.
- Browser
- Download file 465 Bytes
-
https://huggingface.co/spaces/techprotrade/annator-command-center/resolve/main/scripts/utils/flask_async_fix.py
- Command line
-
hf download hf://spaces/techprotrade/annator-command-center/scripts/utils/flask_async_fix.py
-
curl -L -o flask_async_fix.py https://huggingface.co/spaces/techprotrade/annator-command-center/resolve/main/scripts/utils/flask_async_fix.py
465 Bytes
| # Fix for Flask async views | |
| import asgiref.sync | |
| import flask | |
| # Monkey patch Flask to handle async views | |
| original_ensure_sync = flask.Flask.ensure_sync | |
| def patched_ensure_sync(self, func): | |
| if hasattr(func, '__code__') and hasattr(func.__code__, 'co_flags'): | |
| if func.__code__.co_flags & 0x80: # CO_COROUTINE | |
| return asgiref.sync.async_to_sync(func) | |
| return original_ensure_sync(self, func) | |
| flask.Flask.ensure_sync = patched_ensure_sync | |