This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, make_response, redirect, abort | |
app = Flask(__name__) | |
# 基本 | |
@app.route('/') | |
def index(): | |
return '<h1>こんにちは</h1>' | |
# URLからパラメータ受け取り | |
@app.route('/user/<name>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cgi | |
form = cgi.FieldStorage() # フォームからの値の取得 | |
name = form.getvalue('name', '') | |
message = 'ようこそ、' + name + 'さん!' | |
print('Content-type: text/html; charset=UTF-8') # ヘッダ開始 | |
print() # ヘッダ終了、これを省くとヘッダと認識してもらえない。 |