Skip to content

State persistence on reload? #439

Answered by adamfluty
adamfluty asked this question in Q&A
Discussion options

You must be logged in to vote

I figured it out partially...

  1. The flask app needs a secret key to be set to be able to load a session object per session. This is something each dev should put in themselves. It's as easy as:
    flask_app.secret_key = b"very_secret_key"
    and the mesop script can get the flask app instance easily with the current_app variable:
    from flask import current_app
    But note you can only use it within the context of a request for it to work. Not sure how to nicely set this in a Mesop script, such that the secret key can be set before any "real" sessions are started. Probably easy though by using an initial "dead" request just to open the app context so the script can get the instance and set the key...…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@adamfluty
Comment options

@wwwillchen
Comment options

@adamfluty
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by adamfluty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants