PhaniKumar commited on
Commit
252e18c
·
verified ·
1 Parent(s): 8ca76af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -1,7 +1,30 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ def letter_counter(word: str, letter: str) -> int:
4
+ """
5
+ Count the number of occurrences of a letter in a word or text.
6
 
7
+ Args:
8
+ word (str): The input text to search through
9
+ letter (str): The letter to search for
10
+
11
+ Returns:
12
+ int: The number of times the letter appears in the text
13
+ """
14
+ word = word.lower()
15
+ letter = letter.lower()
16
+ count = word.count(letter)
17
+ return count
18
+
19
+ # Create a standard Gradio interface
20
+ demo = gr.Interface(
21
+ fn=letter_counter,
22
+ inputs=["textbox", "textbox"],
23
+ outputs="number",
24
+ title="Letter Counter",
25
+ description="Enter text and a letter to count how many times the letter appears in the text."
26
+ )
27
+
28
+ # Launch both the Gradio web interface and the MCP server
29
+ if __name__ == "__main__":
30
+ demo.launch(mcp_server=True)