image-gen-mcp / app.py
wjlgatech's picture
Create app.py
ebcfb0d verified
raw
history blame
856 Bytes
import gradio as gr
def count_letter(word:str, letter:str) -> int:
"""
Count the occurrences of a letter in a word/text.
Args:
word (str): the input text to search through
letter(str): the letter to search for
Returns:
int: the number of times the letter appears in the word/text.
"""
word = word.lower()
letter = letter.lower()
count = word.count(letter)
return count
# create a standard gradio ui
demo = gr.Interface(
fn=count_letter,
inputs=['textbox', 'textbox'],
outputs='number',
title='Letter Counter',
description="Enter text and a letter to count how many times the letter appears in the text."
)
# launch both the Gradio web interface and the MCP server
if __name__=='__main__':
demo.launch(mcp_server=True,
share=True) #to create a public link