Skip to content

Instantly share code, notes, and snippets.

@gabrielepmattia
Created August 18, 2019 12:35
Show Gist options
  • Save gabrielepmattia/f9f6f4ce5e3312590e24e2631bc7a638 to your computer and use it in GitHub Desktop.
Save gabrielepmattia/f9f6f4ce5e3312590e24e2631bc7a638 to your computer and use it in GitHub Desktop.
Simple Cookie Flask Server
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