2
I created an application in Flask, and can run normally by running only one flask run
, but when I spin, it appears that it is in a production environment. When I switch to the development environment, with $env:FLASK_ENV = "development"
, the application runs, but I get an error whenever I try to make a request.
Here mine __init__.py
from flask import Flask
from .views.mfe import mfe
from .extensions import cors
def create_app(config_file='settings.py'):
app = Flask(__name__)
app.config.from_pyfile(config_file)
cors.init_app(app)
app.register_blueprint(mfe)
return app
And here an example of a view:
mfe = Blueprint('mfe', __name__, url_prefix='/cfe')
@mfe.route('/emissao', methods=['POST'])
def create():
return 'Hello World!'
The error received is as follows::
127.0.0.1 - - [25/Aug/2021 13:38:20] "POST /cfe/emissao HTTP/1.1" 500 -
Traceback (most recent call last):
File "C:\Users\Livia\Documents\my-project\env\Lib\site-packages\flask\cli.py", line 354, in __call__
self._flush_bg_loading_exception()
File "C:\Users\Livia\Documents\my-project\env\Lib\site-packages\flask\cli.py", line 342, in _flush_bg_loading_exception
raise exc_info
TypeError: exceptions must derive from BaseException
127.0.0.1 - - [25/Aug/2021 13:38:21] "GET /cfe/emissao?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
127.0.0.1 - - [25/Aug/2021 13:38:21] "GET /cfe/emissao?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
127.0.0.1 - - [25/Aug/2021 13:38:21] "GET /cfe/emissao?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
127.0.0.1 - - [25/Aug/2021 13:38:21] "GET /cfe/emissao?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -