from fastapi import FastAPI, Request, Form from fastapi.responses import HTMLResponse import nest_asyncio import uvicorn # import gradio as gr from tafsir import tafsir app=FastAPI() @app.on_event("startup") async def startup_event(): global bot bot=tafsir() @app.get("/",response_class=HTMLResponse) async def home(): html_content = """ Tafsir Topic

Topic Input

""" return HTMLResponse(content=html_content, status_code=200) @app.post("/analyze/", response_class=HTMLResponse) async def analyze_text(text: str = Form(...)): # Assuming your model is a function that takes input and returns predictions prediction = bot.return_tafsir(text) html_content = """ Analysis Result

Analysis Result:

Topic: {input_text}

Top 3 results: {prediction}