Created
September 12, 2014 18:21
-
-
Save jnewman/29da20259bd8e4fe91ee to your computer and use it in GitHub Desktop.
Reproduce issue in Firebug network tab
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 datetime import datetime | |
from flask import Flask, render_template, request, make_response | |
from argparse import ArgumentParser | |
app = Flask(__name__) | |
DEFAULT_HOST = 'example.com' | |
app.config['HOST'] = DEFAULT_HOST | |
@app.route('/cookies') | |
def cookies_setter(): | |
resp = make_response(render_template('cookies.html')) | |
now = '{0}'.format(datetime.now()) | |
host = app.config['HOST'] | |
if not request.cookies.get('short'): | |
resp.headers.add( | |
'Set-Cookie', 'short=' + now + '; path=/; domain=.' + host + '; expires=Wed, 11-Mar-15 13:50:34 GMT' | |
) | |
if not request.cookies.get('long'): | |
resp.headers.add( | |
'Set-Cookie', 'long=' + now + '; path=/; domain=.' + host + '; expires=Wed, 11-Mar-2015 00:30:34 GMT;' | |
) | |
if not request.cookies.get('session'): | |
resp.headers.add('Set-Cookie', 'session=' + now + '; path=/; domain=.' + host + ';') | |
return resp | |
@app.route('/show-cookies') | |
def cookies_shower(): | |
resp = make_response(render_template('cookies.html')) | |
return resp | |
if __name__ == '__main__': | |
parser = ArgumentParser() | |
parser.add_argument('-p', '--port', default=9000, help='port to run on', type=int) | |
parser.add_argument('-H', '--host', default=DEFAULT_HOST, help='port to run on', type=str) | |
args = parser.parse_args() | |
app.config['HOST'] = args.host | |
app.run(port=args.port, debug=True) |
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
Flask==0.10.1 | |
Jinja2==2.7.3 | |
MarkupSafe==0.23 | |
Werkzeug==0.9.6 | |
argparse==1.2.1 | |
itsdangerous==0.24 | |
wsgiref==0.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment