I need to test two Flask Apps in my browser at the same time. By standard, Flask runs the app in the localhost:5000. So, a good alternative would be changing the address of one of the apps. Is that possible? If so, how to do it?
Enter application dispatching. With this you can combine multiple Flask applications at the WSGI level. This also allows you to combine any WSGI application. So if you have separate Flask, Django, or Dash applications you can run them in the same interpreter side by side if you want.
Flask will process one request per thread at the same time. If you have 2 processes with 4 threads each, that's 8 concurrent requests. Flask doesn't spawn or manage threads or processes.
As of Flask 1.0, flask server is multi-threaded by default. Each new request is handled in a new thread. This is a simple Flask application using default settings.
Although Flask has a built-in web server, as we all know, it's not suitable for production and needs to be put behind a real web server able to communicate with Flask through a WSGI protocol. A common choice for that is Gunicorn—a Python WSGI HTTP server. Serving static files and proxying request with Nginx.
You can set the addres and port for your app
app.run(host='0.0.0.0',port=12345)
As long as the port numbers don't clash you can run seperate instances of flask apps on the same computer
Since version 0.11, flask run
is the recommended method to start a development server. In your case, open a new terminal, then run the same app on different port:
$ export FLASK_APP=my_app2 # use "set FLASK_APP=my_app2" on Windows
$ flask run --port 5001
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With