Giter Club home page Giter Club logo

Comments (5)

abidlabs avatar abidlabs commented on July 24, 2024

Hi @coolboyqu IIUC you could do something like this:

import gradio as gr

def update_state(request: gr.Request):
    session_hash = request.session_hash
    # do something with session_hash
    return 123

with gr.Blocks() as demo:
    s = gr.State()
    demo.load(update_state, None, s)  # at page load, s will store "123"
    
demo.launch()

if this does not answer your question, please provide more details and a code snippet that explains what you're trying to do. You can ask in this thread, or preferably, for general questions like this (that are not feature requests or bug reports), please ask in our Discord server. (I'll close this issue)

from gradio.

coolboyqu avatar coolboyqu commented on July 24, 2024

Hi @coolboyqu IIUC you could do something like this:

import gradio as gr

def update_state(request: gr.Request):
    session_hash = request.session_hash
    # do something with session_hash
    return 123

with gr.Blocks() as demo:
    s = gr.State()
    demo.load(update_state, None, s)  # at page load, s will store "123"
    
demo.launch()

if this does not answer your question, please provide more details and a code snippet that explains what you're trying to do. You can ask in this thread, or preferably, for general questions like this (that are not feature requests or bug reports), please ask in our Discord server. (I'll close this issue)

I'm sorry I didn't describe my problem clearly. What I meant was to find this session based on its unique identifier. For example, I recorded a row of data {cookie: 'abcde', session identifier: [1,2,3,4,5]} in the database. Before updating this database cookie to a new value, I would like to modify the State of several session operations with cookie 'abcde' based on [1,2,3,4,5]

from gradio.

abidlabs avatar abidlabs commented on July 24, 2024

Its still not clear to me, what is this "session identifier" here?

from gradio.

coolboyqu avatar coolboyqu commented on July 24, 2024

Its still not clear to me, what is this "session identifier" here?

Similar to session hash, a value which can uniquely mark the session.

from gradio.

abidlabs avatar abidlabs commented on July 24, 2024

Ok so I think my code snippet should provide a solution, right? You can access the session_hash and then look it up a db from within your function?

from gradio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.