LoginSignup
17
21

More than 5 years have passed since last update.

もっとも簡単なFlaskの作り方

Posted at

もっとも簡単なFlaskアプリの作り方です。
Webブラウザで http://localhost:3000/hello にアクセスするとjsonファイル(内容は{'result':'hello world!'})の保存ダイアログが表示されます。
※ とある方に「hello worldレベルの説明がほしい」と言われたので

flaskのインストール
pip install flask
hello.py
# -*- coding: utf-8 -*-
from flask import Flask, make_response, jsonify

# flask
app = Flask(__name__)

# rest api
@app.route('/hello', methods=['GET'])
def hello_world():
    return make_response(jsonify({'result':'hello world!'}))

# main
if __name__ == "__main__":
    app.run(host='localhost', port=3000)
17
21
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
17
21