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

@app.route('/<int:x>')
def count(x):
  # See if we already instantiated the list
  s = session.get('sum', None)
  if not s:
    # If it's not there, add our first item.
    session['sum'] = x
  else:
    # If it's there, add the current number
   session['sum']+=x
   # Display current count
  return str(session['sum'])


@app.route('/')
def home():
  return 'Open this page and go to /5 or some other number'

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