from pathlib import Path import gradio as gr from fastapi import FastAPI from fastapi.responses import FileResponse from fastapi.staticfiles import StaticFiles # All website files should be in the same directory as app.py. BASE_DIR = Path(__file__).resolve().parent REQUIRED_FILES = [ "signin.html", "signup.html", "index.html", "dashboard.html", "assessment.html", "practice.html", "speaking.html", "style.css", ] # Check the files before starting the website. missing_files = [ filename for filename in REQUIRED_FILES if not (BASE_DIR / filename).is_file() ] if missing_files: raise FileNotFoundError( "The following RISE website files are missing: " + ", ".join(missing_files) ) # Gradio remains the main application used by Hugging Face Spaces. with gr.Blocks(title="RISE") as demo: gr.HTML( """

RISE

AI-powered social communication coaching

Sign In   |   Create Account

""" ) # Add website routes to the FastAPI app used by Gradio. app = demo.app # Serve CSS, JavaScript, and other static assets from the project folder. # This mounts files at /assets/filename. app.mount( "/assets", StaticFiles(directory=str(BASE_DIR)), name="rise-assets", ) # Serve individual HTML pages. @app.get("/signin.html", include_in_schema=False) async def signin_page(): return FileResponse(BASE_DIR / "signin.html") @app.get("/signup.html", include_in_schema=False) async def signup_page(): return FileResponse(BASE_DIR / "signup.html") @app.get("/index.html", include_in_schema=False) async def home_page(): return FileResponse(BASE_DIR / "index.html") @app.get("/dashboard.html", include_in_schema=False) async def dashboard_page(): return FileResponse(BASE_DIR / "dashboard.html") @app.get("/assessment.html", include_in_schema=False) async def assessment_page(): return FileResponse(BASE_DIR / "assessment.html") @app.get("/practice.html", include_in_schema=False) async def practice_page(): return FileResponse(BASE_DIR / "practice.html") @app.get("/speaking.html", include_in_schema=False) async def speaking_page(): return FileResponse(BASE_DIR / "speaking.html") # Serve the stylesheet at a predictable URL. @app.get("/style.css", include_in_schema=False) async def stylesheet(): return FileResponse( BASE_DIR / "style.css", media_type="text/css", ) if __name__ == "__main__": demo.launch()