1
4

More than 3 years have passed since last update.

Flask入門その1:まずはローカルで動かしてみる&配布用に実行ファイルを作ってみる

Posted at

環境

PC : Mac
開発環境 : Visual Studio Code

まずはローカルでhello worldを動かす

flaskをインストール

pip install flask

実行

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()

ブラウザで確認
http://127.0.0.1:5000/
image.png

非エンジニアに渡して使ってもらえるように、実行ファイル化してみる

実行ファイル化用パッケージをインストール

pip install pyinstaller

実行ファイル化

pyinstaller flask_test.py --onefile

問題なくMac用の実行ファイルを作れた
ちなみに、クロスコンパイラではないのでMacでWindows用の実行ファイルを作ることは出来ないらしい

大いに参考にさせてもらったサイトたち

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4