""" Simple Gradio app for Hugging Face Spaces to display and offer the CapCut article HTML for download. Place this file inside: capcutmodapk/app.py Make sure you add a requirements.txt with: gradio This app will: - Load `capcut-article.html` (created earlier) if present - Render the HTML inside the Space using gr.HTML - Provide a download button (gr.File) for the HTML file """ import os from pathlib import Path import gradio as gr HERE = Path(__file__).parent HTML_FILE = HERE / "capcut-article.html" # read the article html if it exists if HTML_FILE.exists(): article_html = HTML_FILE.read_text(encoding="utf-8") else: article_html = "

CapCut Article Not Found

Please add capcut-article.html to this folder.

" def provide_file(): """Return path to the HTML file so Gradio's File component can serve it for download.""" if HTML_FILE.exists(): return str(HTML_FILE.resolve()) return None def make_interface(): with gr.Blocks(title="CapCut Article Viewer") as demo: gr.Markdown("# CapCut Article — Viewer & Download") gr.Markdown("This Space displays the CapCut article and provides a download link for the HTML file.\n\nIf you want to edit the article, open `capcut-article.html` in the repository and commit your changes.") with gr.Row(): with gr.Column(scale=3): # Render article HTML (safe for Spaces) gr.HTML(article_html, elem_id="article-view") with gr.Column(scale=1): gr.Markdown("### Download") file_output = gr.File(value=provide_file(), label="Download capcut-article.html") gr.Markdown("---") gr.Markdown("### Repo structure expected:\n\n```\nthecupcutapk/\n capcutmodapk/\n app.py\n capcut-article.html\n```\n\nIf `capcut-article.html` is missing, add it to the folder and re-run the Space.") gr.Markdown("---\nMade for Hugging Face Spaces — simple, static article viewer.\n") return demo app = make_interface() if __name__ == "__main__": # For local testing: python app.py app.launch(server_name="0.0.0.0", server_port=7860)