7
5

More than 3 years have passed since last update.

PythonとFlaskをインストールする(Windows10)

Posted at

参考サイト

Python3.7のインストール
https://www.python.org/downloads/release/python-376/

上記からインストーラタイプ(Windows x86-64 executable installer)をDL

インストールする(もし、PATHが通っていなかった場合は再実行し
Modify→add python to environment variablesにチェックを入れ再インストール

インストールされているか確認

python -V

Python 3.7.6

Pythonインストール確認後、下記コマンドでFlaskをインストール

pip install flask

作業ディレクトリにmain.pyを作成し、以下を記述

#coding:utf-8

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    return "Hallo World!"

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

#デバッグモードTrueにすると変更が即反映される
#ファイルのエンコードはUTF-8で保存すること
#下記URLをブラウザに打ち込むとページが開く
# http://127.0.0.1:5000/

その後、作業ディレクトリで以下のコマンドを実行

python main.py

アプリが実行されるので、http://127.0.0.1:5000/ へアクセスして確認

7
5
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
7
5