16 lines
493 B
Python
16 lines
493 B
Python
from flask import Flask, render_template, request, make_response
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/', methods=['POST', 'GET'])
|
|
def index():
|
|
if request.method == 'GET':
|
|
name = request.cookies.get('name')
|
|
return render_template('cookies.html', name=name)
|
|
else:
|
|
name = request.form['name']
|
|
resp = make_response(render_template('cookies.html', name=name))
|
|
resp.set_cookie('name', name)
|
|
return resp
|
|
|
|
if __name__ == '__main__':
|
|
app.run() |