Here are the examples of the python api flask.request.cookies.get taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
24 Examples
3
Example 1
Project: pluss Source File: main.py
@app.route("/")
def main():
"""Display the homepage."""
gplus_id = flask.request.cookies.get('gplus_id')
if gplus_id:
# If we lost rights, but someone still has the cookie, get rid of it.
if not TokenIdMapping.lookup_refresh_token(gplus_id):
return flask.redirect(flask.url_for('clear'))
# Display a page indicating the user's feed URL, since they've authed.
return flask.render_template('authed_main.html', datetime=datetime, gplus_id=gplus_id,
feed_url=full_url_for('user_atom', gplus_id=gplus_id))
else:
return flask.render_template('main.html', datetime=datetime)
3
Example 2
Project: pybossa Source File: core.py
def setup_babel(app):
"""Return babel handler."""
babel.init_app(app)
@babel.localeselector
def _get_locale():
locales = [l[0] for l in app.config.get('LOCALES')]
if current_user.is_authenticated():
lang = current_user.locale
else:
lang = request.cookies.get('language')
if (lang is None or lang == '' or
lang.lower() not in locales):
lang = request.accept_languages.best_match(locales)
if (lang is None or lang == '' or
lang.lower() not in locales):
lang = app.config.get('DEFAULT_LOCALE') or 'en'
return lang.lower()
return babel
3
Example 3
def image_authn(self):
"""Check to see if user if authenticated for image requests."""
self.logger.info("image_authn: loggedin cookie = " +
request.cookies.get(self.token_cookie_name, default='[none]'))
# FIXME - check value
return request.cookies.get(self.token_cookie_name, default='')
3
Example 4
def image_authn(self):
"""Check to see if user if authenticated for image requests.
Must have auth cookie with known token value.
"""
self.logger.info("image_authn: auth cookie = " +
request.cookies.get(self.auth_cookie_name, default='[none]'))
return request.cookies.get(self.auth_cookie_name, default='')
3
Example 5
def open_session(self, app, request):
session_id = request.cookies.get(app.session_cookie_name)
if not session_id:
session_id = self.generate_session_id()
session = Session.get(session_id=session_id)
data = json.loads(session.values)
mongo = MongoSession(session_id=session_id, data=data)
if session.expired(self.get_mongo_expiration_time(app,mongo)):
Session.delete(session_id=session_id)
session = Session.new(session_id=session_id)
mongo = MongoSession(session_id=session_id)
return mongo
3
Example 6
@babel.localeselector
def get_locale():
locale = 'en' # request.accept_languages.best_match(LANGUAGES.keys())
if request.cookies.get('lang') in LANGUAGES.keys():
locale = request.cookies.get('lang')
if request.args.get('lang') in LANGUAGES.keys():
locale = request.args.get('lang')
return locale
3
Example 7
Project: lastuser Source File: helpers.py
def autoset_timezone(user):
# Set the user's timezone automatically if available
if user.timezone is None or user.timezone not in valid_timezones:
if request.cookies.get('timezone'):
timezone = unquote(request.cookies.get('timezone'))
if timezone in valid_timezones:
user.timezone = timezone
3
Example 8
def open_session(self, app, request):
sid = request.cookies.get(app.session_cookie_name)
if not sid:
return self.session_class(sid=self.generate_sid(), new=True)
data = self.storage.get(sid)
if data is not None:
return self.session_class(self.serializer.loads(data), sid=sid)
return self.session_class(sid=self.generate_sid(), new=True)
3
Example 9
@app.route("/dashboard", methods=['GET'])
def dashboard():
try:
sid = request.cookies.get('session_id', False)
if sid and db.get(sid, False):
return redirect('main.html'), 200, html_header
else:
response = make_response(redirect(url_for('root')))
response.set_cookie('session_id', None)
return response
except Exception as e:
print e
3
Example 10
Project: InstaStat Source File: main.py
@app.route("/dashboard/user_details", methods=['GET'])
def dashboard_user_details():
sid = request.cookies.get('session_id', False)
if sid and db.get(sid, False):
user = handler.UserDetails(access_token=db.get(sid))
resp = user.get()
return resp, 200, json_header
else:
return jsonify(**f), 200,json_header
3
Example 11
Project: InstaStat Source File: main.py
@app.route("/dashboard/fans", methods=['GET'])
def dashboard_fans():
try:
sid = request.cookies.get('session_id', False)
if sid and db.get(sid, False):
fans = handler.MyFans(access_token=db.get(sid))
resp = fans.get()
return resp, 200, json_header
else:
return jsonify(**f), 200,json_header
except Exception as e:
print e
3
Example 12
Project: InstaStat Source File: main.py
@app.route("/dashboard/non_followers", methods=['GET'])
def dashboard_non_followers():
sid = request.cookies.get('session_id', False)
if sid and db.get(sid, False):
non_followers = handler.MyNonFollowers(access_token=db.get(sid))
resp = non_followers.get()
return resp, 200, json_header
else:
return jsonify(**f), 200,json_header
3
Example 13
@app.route("/follow", methods=['GET'])
def follow():
sid = request.cookies.get('session_id', False)
if sid and db.get(sid, False):
id = request.args.get("id")
#print(id)
if helper.follow(access_token=db.get(sid),userid=id):
return "Successfully followed"
else:
return "Some Error Occured", 400
else:
return jsonify(**f), 200,json_header
3
Example 14
@app.route("/unfollow", methods=['GET'])
def unfollow():
sid = request.cookies.get('session_id', False)
if sid and db.get(sid, False):
id = request.args.get("id")
#print id
#return "Successfully Unfollowed"
if helper.unfollow(access_token=db.get(sid),userid=id):
return "Successfully Unfollowed"
else:
return "Some Error Occured", 400
else:
return jsonify(**f), 200,json_header
3
Example 15
def do_login(backend, user, social_user):
name = backend.strategy.setting('REMEMBER_SESSION_NAME', 'keep')
remember = backend.strategy.session_get(name) or \
request.cookies.get(name) or \
request.args.get(name) or \
request.form.get(name) or \
False
return login_user(user, remember=remember)
0
Example 16
Project: flask-jwt-extended Source File: utils.py
def _decode_jwt_from_cookies(type):
if type == 'access':
cookie_key = get_access_cookie_name()
else:
cookie_key = get_refresh_cookie_name()
token = request.cookies.get(cookie_key)
if not token:
raise NoAuthorizationError('Missing cookie "{}"'.format(cookie_key))
secret = _get_secret_key()
algorithm = get_algorithm()
token = _decode_jwt(token, secret, algorithm)
if get_cookie_csrf_protect():
csrf_header_key = get_csrf_header_name()
csrf = request.headers.get(csrf_header_key, None)
if not csrf or not safe_str_cmp(csrf, token['csrf']):
raise NoAuthorizationError("Missing or invalid csrf double submit header")
return token
0
Example 17
Project: WatchPeopleCode Source File: models.py
def already_subscribed(self, streamer):
email = request.cookies.get("email")
return email and streamer and get_or_create(Subscriber, email=email) in streamer.subscribers
0
Example 18
def is_authenticated(self):
if config.get('CONFIG_PASSWORD', None) and not request.cookies.get("auth") == config['AUTH_KEY']:
return False
else:
return True
0
Example 19
Project: discograph Source File: ui.py
@blueprint.route('/')
def route__index():
import discograph
app = current_app._get_current_object()
is_a_return_visitor = request.cookies.get('is_a_return_visitor')
initial_json = 'var dgData = null;'
on_mobile = request.MOBILE
parsed_args = helpers.parse_request_args(request.args)
original_roles, original_year = parsed_args
if not original_roles:
original_roles = default_roles
multiselect_mapping = discograph.CreditRole.get_multiselect_mapping()
url = url_for(
request.endpoint,
roles=original_roles,
)
rendered_template = render_template(
'index.html',
application_url=app.config['APPLICATION_ROOT'],
initial_json=initial_json,
is_a_return_visitor=is_a_return_visitor,
multiselect_mapping=multiselect_mapping,
og_title='Disco/graph: visualizing music as a social graph',
og_url=url,
on_mobile=on_mobile,
original_roles=original_roles,
original_year=original_year,
title='Disco/graph: Visualizing music as a social graph',
)
response = make_response(rendered_template)
response.set_cookie('is_a_return_visitor', 'true')
return response
0
Example 20
Project: github-stats Source File: welcome.py
@app.route('/people/')
def person():
limit = int(util.param('limit', int) or flask.request.cookies.get('limit') or config.MAX_DB_LIMIT)
order = util.param('order') or '-stars'
if 'repo' in order:
order = '-public_repos'
elif 'follower' in order:
order = '-followers'
person_dbs, person_cursor = model.Account.get_dbs(
order=order,
organization=False,
limit=limit,
)
response = flask.make_response(flask.render_template(
'account/list_person.html',
title='Top People',
html_class='account-person',
person_dbs=person_dbs,
order=order,
limit=limit,
))
response.set_cookie('limit', str(limit))
return response
0
Example 21
Project: github-stats Source File: welcome.py
@app.route('/organizations/')
def organization():
limit = int(util.param('limit', int) or flask.request.cookies.get('limit') or config.MAX_DB_LIMIT)
order = util.param('order') or '-stars'
if 'repo' in order:
order = '-public_repos'
organization_dbs, organization_cursor = model.Account.get_dbs(
order=order,
organization=True,
limit=limit,
)
response = flask.make_response(flask.render_template(
'account/list_organization.html',
title='Top Organizations',
html_class='account-organization',
organization_dbs=organization_dbs,
order=order,
limit=limit,
))
response.set_cookie('limit', str(limit))
return response
0
Example 22
Project: github-stats Source File: welcome.py
@app.route('/repositories/')
def repo():
limit = int(util.param('limit', int) or flask.request.cookies.get('limit') or config.MAX_DB_LIMIT)
order = util.param('order') or '-stars'
if 'fork' in order:
order = '-forks'
repo_dbs, repo_cursor = model.Repo.get_dbs(
order=order,
limit=limit,
)
response = flask.make_response(flask.render_template(
'account/list_repo.html',
title='Top Repositories',
html_class='account-repo',
repo_dbs=repo_dbs,
order=order.replace('-', ''),
limit=limit,
))
response.set_cookie('limit', str(limit))
return response
0
Example 23
def get_cookie(key):
"""
Get cookie
"""
return request.cookies.get(key)
0
Example 24
Project: open-hackathon Source File: __init__.py
@app.route('/')
@app.route('/index')
def index():
landing_page_visited = request.cookies.get('ohplpv')
if not landing_page_visited:
return redirect("/landing")
empty_items = {
"items": []
}
newest_hackathons = __get_api(API_HACKATHON_LIST, {"token": session.get("token")},
params={"page": 1, "per_page": 6, "order_by": "create_time", "status": 1})
hot_hackathons = __get_api(API_HACKATHON_LIST, {"token": session.get("token")},
params={"page": 1, "per_page": 6, "order_by": "registered_users_num", "status": 1})
soon_hackathon = __get_api(API_HACKATHON_LIST, {"token": session.get("token")},
params={"page": 1, "per_page": 6, "order_by": "event_start_time", "status": 1})
newest_hackathons = empty_items if "error" in newest_hackathons else newest_hackathons
hot_hackathons = empty_items if "error" in hot_hackathons else hot_hackathons
soon_hackathon = empty_items if "error" in soon_hackathon else soon_hackathon
return render('/home.html', newest_hackathons=newest_hackathons, hot_hackathons=hot_hackathons,
soon_hackathon=soon_hackathon, sc=False)