@misingnoglic/

session flask test

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from flask import Flask, render_template, session
app = Flask(__name__)
# Add these extra two lines
app.secret_key = 's3cr3t'
app.config['SESSION_TYPE'] = 'filesystem'

@app.route('/')
def home():
  x = session.get('x', None) 
  if not x:
    session['x'] = 1
  elif x>=10:
    session.clear()
    return "Session Cleared"
  else:
   session['x']+=1
  return "Number of refreshes: "+str(session['x'])

if __name__ == '__main__':
  app.run(host='0.0.0.0')