Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| ''' | |
| def get_params(text, request: gr.Request): | |
| if request: | |
| # Get parameters as a dictionary | |
| params = dict(request.query_params) | |
| print("All parameters:", params) | |
| # Access a specific parameter, e.g., ?user=John | |
| user = params.get("user", "Unknown") | |
| return f"Hello {user}! You typed: {text}" | |
| return f"No request found. Typed: {text}" | |
| with gr.Blocks() as demo: | |
| input_text = gr.Textbox(label="Input") | |
| output_text = gr.Textbox(label="Output") | |
| btn = gr.Button("Submit") | |
| btn.click(fn=get_params, inputs=input_text, outputs=output_text) | |
| demo.launch() | |
| ''' | |
| ''' | |
| def greet(name): | |
| return "Hello " + name + " !!" | |
| demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| demo.launch() | |
| ''' | |
| # Use HF_TOKEN secret | |
| # secret_token = os.environ.get("HF_TOKEN") | |
| secret_token = os.environ.get("testPvtReadSecret1") #testPvtReadSecret1 #vmTokenR1 | |
| print("hello " , secret_token) | |
| demo = gr.load("lmrgroupai/testPvt", src="spaces", token=secret_token) | |
| demo.launch() | |