[PYTHON] Introduction to Flask Part 1: First try running it locally & create an executable file for distribution

environment

PC : Mac Development environment: Visual Studio Code

First, run hello world locally

install flask

pip install flask

Run

from flask import Flask
app = Flask(__name__)
 
@app.route('/')
def hello_world():
    return '''
        <html>
            <body>
                <h1>hello world</h1>
            </body>
        </html>
        '''

if __name__ == '__main__':
    app.run()

Check with browser http://127.0.0.1:5000/ image.png

Try to make it an executable file so that it can be passed to non-engineers for use

Install the package for executable file

pip install pyinstaller

Executable file

pyinstaller flask_test.py --onefile

I was able to create an executable file for Mac without any problems By the way, it seems that it is not possible to create an executable file for Windows on Mac because it is not a cross compiler.

Sites that were very helpful

Recommended Posts

Introduction to Flask Part 1: First try running it locally & create an executable file for distribution
[For Python] Quickly create an upload file to AWS Lambda Layer
An introduction to Mercurial for non-engineers
An introduction to Python for non-engineers
(For myself) Flask_5 (Add to txt file)
An introduction to Python for machine learning
An introduction to Python for C programmers
I made a package to create an executable file from Hy source code
An introduction to machine learning for bot developers
An introduction to object-oriented programming for beginners by beginners
Create an executable file in a scripting language
An introduction to statistical modeling for data analysis
Try to create an HTTP server using Node.js
An introduction to voice analysis for music apps
Try posting to Qiita for the first time
How to use NUITKA-Utilities hinted-compilation to easily create an executable file from a Python script