Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def count_letter(word:str, letter:str) -> int:
|
4 |
+
"""
|
5 |
+
Count the occurrences of a letter in a word/text.
|
6 |
+
Args:
|
7 |
+
word (str): the input text to search through
|
8 |
+
letter(str): the letter to search for
|
9 |
+
Returns:
|
10 |
+
int: the number of times the letter appears in the word/text.
|
11 |
+
"""
|
12 |
+
word = word.lower()
|
13 |
+
letter = letter.lower()
|
14 |
+
count = word.count(letter)
|
15 |
+
return count
|
16 |
+
|
17 |
+
# create a standard gradio ui
|
18 |
+
demo = gr.Interface(
|
19 |
+
fn=count_letter,
|
20 |
+
inputs=['textbox', 'textbox'],
|
21 |
+
outputs='number',
|
22 |
+
title='Letter Counter',
|
23 |
+
description="Enter text and a letter to count how many times the letter appears in the text."
|
24 |
+
)
|
25 |
+
# launch both the Gradio web interface and the MCP server
|
26 |
+
if __name__=='__main__':
|
27 |
+
demo.launch(mcp_server=True,
|
28 |
+
share=True) #to create a public link
|