phenixrhyder commited on
Commit
536014f
·
unverified ·
1 Parent(s): 7507a23

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import gradio as gr
4
+
5
+ # --- 1. DEFINE YOUR CORE FUNCTION ---
6
+ # This is a simple placeholder function. It takes some text as input
7
+ # and returns a slightly modified version of it.
8
+ def process_text(input_text):
9
+ """
10
+ This function takes a string and returns a new string.
11
+ """
12
+ # for debugging, this will show up in the logs of your Hugging Face Space
13
+ print(f"Processing input: {input_text}")
14
+
15
+ # The actual logic of our simple app
16
+ output_text = f"The app received your message: '{input_text}'"
17
+ return output_text
18
+
19
+
20
+ # --- 2. CREATE THE GRADIO INTERFACE ---
21
+ # This creates the web UI that users will see and interact with.
22
+ with gr.Blocks() as demo:
23
+ gr.Markdown("# My First Hugging Face App")
24
+ gr.Markdown("This is a simple demo. Type something in the box and click the button.")
25
+
26
+ # Define the input component (a textbox)
27
+ input_component = gr.Textbox(label="Your Message")
28
+
29
+ # Define the output component
30
+ output_component = gr.Textbox(label="App's Response")
31
+
32
+ # Define the button that will trigger the function
33
+ process_button = gr.Button("Submit")
34
+
35
+ # Link the button to your function.
36
+ # When the button is clicked, it will run the `process_text` function.
37
+ process_button.click(
38
+ fn=process_text,
39
+ inputs=input_component,
40
+ outputs=output_component
41
+ )
42
+
43
+
44
+ # --- 3. LAUNCH THE APP ---
45
+ # This command starts the web server when Hugging Face runs the script.
46
+ if __name__ == "__main__":
47
+ demo.launch()