ap1 / app.py
SanthiSastra's picture
Update app.py
2c4115e verified
raw
history blame contribute delete
599 Bytes
import gradio as gr
def clean_text(s: str) -> str:
# Remove empty lines and trim each line
s = "\n".join([line.strip() for line in s.splitlines() if line.strip()])
# Collapse multiple spaces into single spaces
s = " ".join(s.split())
return s
demo = gr.Interface(
fn=clean_text,
inputs=gr.Textbox(lines=6, label="Paste your text"),
outputs=gr.Textbox(lines=6, label="Cleaned output"),
title="Simple Text Cleaner (Deployed on HF Spaces)",
description="A beginner-friendly app hosted on Hugging Face Spaces.",
)
if __name__ == "__main__":
demo.launch()