LoginSignup
2
4

More than 5 years have passed since last update.

Raspberrypi3にFlaskをインストールする

Last updated at Posted at 2016-10-03

pipインストール

  • pipをインストールしていない場合
sudo apt-get install python-pip

Flaskのインストール

sudo pip install flask

サンプルプログラム作成

  • 下記ソースをhello.pyとして保存する。
hello.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return "Hello World!"

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=80, debug=True)

サンプルプログラム実行

sudo python hello.py

結果確認

下記コマンド結果で"Hello World!"と表示されたら成功です。
(ブラウザでアクセスでも可)

  • raspberrypiのTerminal上で
curl localhost
  • 他端末(ローカルネットワーク内)上で
curl raspberrypiのipアドレス

参考

クイックスタート

2
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
2
4