Spaces:
Running
Running
import gradio as gr | |
import logging | |
# Configure logging to log to a file with .log extension | |
logging.basicConfig(filename="mcp_server.log", level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s", filemode="a") | |
logger = logging.getLogger(__name__) | |
def letter_counter(word, letter): | |
"""Count the occurrences of a specific letter in a word. | |
Args: | |
word: The word or phrase to analyze | |
letter: The letter to count occurrences of | |
Returns: | |
The number of times the letter appears in the word | |
""" | |
logger.info(f"Called letter_counter with word='{word}', letter='{letter}'") | |
count = word.lower().count(letter.lower()) | |
logger.info(f"Count result: {count}") | |
return count | |
logger.info("Creating Gradio Interface for letter_counter.") | |
demo = gr.Interface( | |
fn=letter_counter, | |
inputs=["text", "text"], | |
outputs="number", | |
title="Letter Counter", | |
description="Count how many times a letter appears in a word" | |
) | |
logger.info("Launching Gradio Interface with MCP server mode.") | |
demo.launch(mcp_server=True,share=True) | |