flask cookckies

Solutions on MaxInterview for flask cookckies by the best coders in the world

showing results for - "flask cookckies"
Jasmine
16 Feb 2020
1from flask import Flask, render_template, make_response, request
2id_list = [0]
3
4@app.route('/')
5def setcookie():
6  resp = make_response(render_template('index.html'))
7  resp.set_cookie('id', id_list[len(id_list) - 1] + 1)
8  id_list.append(id_list[len(id_list) - 1] + 1)
9  return resp
10
11@app.route('/show_id')
12def show_id():
13  return f'<h1>welcome {request.cookies.get("id")} </h1>'
14