Create one executable file for a Flask app with PyInstaller

  1. pip3 install pyinstaller

  2. we have a sample flask app server.py

    from flask import Flask
    server = Flask(__name__)
    @server.route("/")
    def hello():
        return "Hello World!"
    if __name__ == "__main__":
    server.run(host='0.0.0.0')
  3. pyinstaller -F server.py
    it will create a executable file server in ./dist

  4. verify the executable file

    root@labvm:~/python_docker/src/dist# ./server
    * Serving Flask app "server" (lazy loading)
    * Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
    * Debug mode: off
    * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

if you have static and templates folder and other py files, you can run command like:
pyinstaller -F -i BreezePython.ico --add-data="HttpServer\static;HttpServer\static" --add-data="HttpServer\templates;Httpserver\templates" --add-data="settings.py;." manage.py

5 Replies to “Create one executable file for a Flask app with PyInstaller”

  1. Wonderful beat ! I wish to apprentice while you amend your site, how can i subscribe for a blog website? The account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept Caryn Skip Proud

  2. Thank you so much for giving everyone such a pleasant opportunity to check tips from this blog. It can be very kind and stuffed with a lot of fun for me and my office colleagues to visit the blog at the very least three times every week to read the new items you will have. Of course, I am just always fulfilled with your extraordinary concepts you serve. Selected 3 areas in this post are in reality the most suitable we have all had. Josie Roderick Wulf

  3. great points altogether, you just gained a brand new reader. What would you recommend in regards to your post that you made some days ago? Any positive? Tabbatha Mordy Baptlsta

Leave a Reply

Your email address will not be published. Required fields are marked *