Created
August 18, 2019 12:35
-
-
Save gabrielepmattia/f9f6f4ce5e3312590e24e2631bc7a638 to your computer and use it in GitHub Desktop.
Simple Cookie Flask Server
This file contains hidden or 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, render_template, request, redirect, url_for, flash, make_response | |
import time | |
MYCOOKIE_KEY = "mycookie" | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): | |
return 'cookies=' + str(request.cookies) | |
@app.route('/set-cookie') | |
def set_cookie(): | |
uid = str(time.time()) | |
resp = make_response("set cookie: " + uid) | |
resp.set_cookie(MYCOOKIE_KEY, uid) | |
return resp | |
app.run(host="0.0.0.0", port="8989") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment