Run Flask application locally, without a complex web server

I created a small app for a friend. This computer will not be connected to the Internet while using the application, so hosting it on Heroku is not an option.

Is there a way to deploy it locally without installing a complex web server? Something small to pack with the app? Using the built-in Flask server seems discouraged when you go to "production", but is this okay for a local application?

+3


source to share


2 answers


If it will be used autonomously by one person, then yes, perhaps an internal development server might suffice.

If you're looking for an easy way to ship this application, see pyinstaller :

pip install pyinstaller
pyinstaller your_app.py

      



Close the folder inside the new dist directory and pipe this.

If pyinstaller isn't for you, there are tons of options .

+2


source


If you're just running the application locally, you should be fine. The main issues with the dev server are security and performance, but for an application that doesn't run externally and has one user, it should work fine. Even though you are using dev server, it is still recommended to disable debug mode and enable multiprocessing mode.

from multiprocessing import cpu_count
app.run(debug=False, processes=cpu_count())

      



If you want a little performance boost, consider using uwsgi or gunicorn. Both are good WSGI application servers that can be installed along with the application along with your application.

gunicorn -w $(nproc) --threads 2 --max-requests 10 myproject:app

      

+3


source







All Articles