Labbits commited on
Commit
2b7a2fc
·
verified ·
1 Parent(s): d1efe30

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Source: https://www.gradio.app/guides/building-mcp-server-with-gradio
2
+ import gradio as gr
3
+
4
+ def letter_counter(word, letter):
5
+ """
6
+ Count the number of occurrences of a letter in a word or text.
7
+
8
+ Args:
9
+ word (str): The input text to search through
10
+ letter (str): The letter to search for
11
+
12
+ Returns:
13
+ str: A message indicating how many times the letter appears
14
+ """
15
+ word = word.lower()
16
+ letter = letter.lower()
17
+ count = word.count(letter)
18
+ return count
19
+
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
+ if __name__ == "__main__":
29
+ demo.launch(mcp_server=True)