File size: 875 Bytes
3ee08f9
 
45f7450
3ee08f9
 
 
45f7450
 
3ee08f9
 
 
 
 
2918c71
 
3ee08f9
 
45f7450
3ee08f9
 
 
 
 
 
 
3053305
3ee08f9
 
 
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
28
29
30
import gradio as gr
import json
import uuid 

# Define a function that takes a JSON object as input
def process_json(input_json):
    id = uuid.uuid1() 
    
    # Parse the JSON object
    data = json.loads(input_json)
    
    # Your logic here to process the data
    # For example, let's say we want to extract a "name" field from the JSON
    user_id = data.get("user_id", "Unknown")
    user_token = data.get("user_token", "Unknown")

    # Create a response JSON object
    response_json = {"message": f"Hello, {user_id}!{user_token} random uuid {id.int}"}

    # Convert the response JSON object to a string
    response_str = json.dumps(response_json)
    
    return response_str

# Create a Gradio interface for the function that accepts JSON input
iface = gr.Interface(fn=process_json, inputs='text', outputs='json')

# Launch the Gradio interface
iface.launch()