What's happening
While going through app.py I noticed that all the session state — word,
last_letter, letter_start_time, current_letter, and confidence — is
stored as plain module-level Python globals.
# app.py (lines 28–35)
current_letter = ""
confidence = 0.0
word = ""
last_letter = ""
letter_start_time = None
auto_add_delay = 5
Since Flask (and Gunicorn in the Procfile) serves requests concurrently, every
browser tab — or every user on the live Render deployment — reads and writes
these same variables with no isolation between them.
What goes wrong
Open two browser tabs at the same time and try signing different letters:
- Tab 2's prediction overwrites
last_letter, which resets the auto-add timer
for Tab 1 — so letters either get added too early or never at all
- Clicking Reset or Undo in one tab silently clears the word for
every other active session
- The
/get_word route returns a word built from a mix of inputs from
different users
This also affects the live demo at aslproject-0oyu.onrender.com since
multiple visitors can hit it at the same time.
Suggested fix
Flask has a built-in session object (cookie-backed, per-user) that would
handle this cleanly — no extra dependencies needed.
from flask import session
import secrets
app.secret_key = secrets.token_hex(32)
# Inside /predict — read/write from session instead of globals
word = session.get('word', '')
last_letter = session.get('last_letter', '')
letter_start_time = session.get('letter_start_time', None)
# ... existing logic unchanged ...
session['word'] = word
session['last_letter'] = last_letter
session['letter_start_time'] = letter_start_time
The same pattern applies to /add_letter, /undo_letter, /reset, and
/get_word. Only app.py needs to change.
Affected file
Notes
Happy to open a PR for this if the approach sounds good to maintainers @Sant60 .
It's a fairly self-contained change and easy to verify by opening two tabs.
What's happening
While going through
app.pyI noticed that all the session state —word,last_letter,letter_start_time,current_letter, andconfidence— isstored as plain module-level Python globals.
Since Flask (and Gunicorn in the Procfile) serves requests concurrently, every
browser tab — or every user on the live Render deployment — reads and writes
these same variables with no isolation between them.
What goes wrong
Open two browser tabs at the same time and try signing different letters:
last_letter, which resets the auto-add timerfor Tab 1 — so letters either get added too early or never at all
every other active session
/get_wordroute returns a word built from a mix of inputs fromdifferent users
This also affects the live demo at
aslproject-0oyu.onrender.comsincemultiple visitors can hit it at the same time.
Suggested fix
Flask has a built-in
sessionobject (cookie-backed, per-user) that wouldhandle this cleanly — no extra dependencies needed.
The same pattern applies to
/add_letter,/undo_letter,/reset, and/get_word. Onlyapp.pyneeds to change.Affected file
app.pyNotes
Happy to open a PR for this if the approach sounds good to maintainers @Sant60 .
It's a fairly self-contained change and easy to verify by opening two tabs.