[problem description]
The author encountered a classic error in flash. The error information is as follows:
[problem analysis]
application context is the application context of Flask, which contains variables such as app and g. When it is not convenient to operate app, we use current_app instead of app. current_app can only be accessed when processing requests, and I used current_app outside of processing requests, so an error was reported. Specifically, I used current_app in a custom tool class, ran the program, and could not get the application context when the program loaded the tool class, so the error was reported. The error code is as follows.
[problem-solving]
Since you can’t use current_app in the class property in the tool class, comment out the code and put it in the class method, and modify it as follows. The class method defined by me is used in the view, so the current_app is used in the view when processing the request, so no error will be reported and the problem is solved.
Read More:
- [Solved] RuntimeError: No application found. Either work inside a view function or push an application contex
- [Solved] Python Project Error: django.core.exceptions.ImproperlyConfigured: WSGI application ‘WebTool.wsgi.application
- Django WSGI protocol application, based on wsgiref module DIY a web framework
- The anaconda-navigator interface cannot be started, loading application, report ERROR download_api._get_url error
- [Solved] Python2 Flask startup error: [Errno 10053]
- Gunicorn Flask Error: [ERROR] Socket error processing request
- [Solved] Vite build & Flask Error: Failed to load module script. Strict MIME type checking is enforced
- [Solved] Windows Python Upzip rar File Error: Cannot find working tool
- [Solved] FLask Error: AttributeError: ‘Blueprint‘ object has no attribute ‘register_blueprint‘
- Python RarFile unpack RAR package Error Rarfile.RarCannotExec: Cannot find Working Tool
- [Solved] flask db migrate execute error: ERROR [flask_migrate] Error: Can‘t locate revision identified by ‘8d1ad59dc71a‘
- Flask Database Migration Error: ERROR [flask_migrate] Error: Can‘t locate revision identified by ‘a1c25fe0fc0e‘
- [Solved] python tqdm raise RuntimeError(“cannot join current thread“) RuntimeError: cannot join current thr
- [Solved] supervisor Error: /usr/local/lib/python2.7/dist-packages/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
- [Solved] Pyinstaller Package and Run Error: RuntimeError: Unable to open/read ui device
- [Solved] RuntimeError: cuda runtime error: device-side assert trigger
- [Solved] RuntimeError: run loop already started raise RuntimeError(‘run loop already started‘)
- RuntimeError: stack expects each tensor to be equal size [How to Solve]
- RuntimeError: CUDA error: an illegal memory access was encountered
- RuntimeError: Address already in use [How to Solve]