Flask-SocketIO in production with wsgi server using executable

Created on 5 May 2020  路  7Comments  路  Source: miguelgrinberg/Flask-SocketIO

Hi, i am using Flask-SocketIO on my flask app and running my app like this

socketio.run(app, port=16482)

I made an excutable of this flask project using

pyinstaller -w -F --add-data='./app/templates:templates' project.py

This executable working fine.

Now i want to deploy it on production using wsgi server as suggested by flask docs.
How can i do this using executable?
I am using Ubuntu 18.04.4 LTS.

question

Most helpful comment

@mindbrokers you asked my opinion, and I gave it to you. I have nothing to do with pyinstaller and I don't use it myself. I feel you should take this conversation over to their user forum.

All 7 comments

i found this link
https://github.com/miguelgrinberg/python-socketio/blob/master/examples/server/wsgi/app.py
Its not using flask-socketio but instead python-socketio.
I know python-socketio is the dependency of former.
Can you please help how to proceed further?

The socketio.run() method of running the app is good for production as long as you use it alongside a production-ready web server such as the ones from eventlet or gevent. Are you using either one of these frameworks already? If you are, then you're good to go, your server is production ready.

If you are not using eventlet or gevent with your app, then you are using the Flask development web server, which is not production ready. Add eventlet or gevent+gevent-websocket to your project to switch to one of these more robust web servers.

Is it safe to use executable in production environment made using pyinstaller?

@mindbrokers I cannot really comment on this as I have never used pyinstaller besides quick tests. You should keep in mind that if you distribute your executable to others, then any secrets, api keys, etc. that you have in it will likely be very easy to extract. Also the source code itself will be easy to access.

Then what is the use of pyinstaller if i cannot distribute my executable?

@mindbrokers you asked my opinion, and I gave it to you. I have nothing to do with pyinstaller and I don't use it myself. I feel you should take this conversation over to their user forum.

Thanks for the help.

Was this page helpful?
0 / 5 - 0 ratings