import os import time import uvicorn import threading from fastapi import FastAPI, Form from fastapi.responses import HTMLResponse, FileResponse app = FastAPI() file_name = None # Store downloaded file name @app.get("/", response_class=HTMLResponse) def home(): return """ Fast File Downloader

Fast File Downloader

""" @app.post("/start-download") def start_download(url: str = Form(...)): global file_name file_name = url.split("/")[-1] # Extract file name from URL os.system(f'wget --no-check-certificate -O "{file_name}" "{url}"') return {"message": f"Download complete: {file_name}", "local_url": f"/download"} @app.get("/download") def serve_file(): if file_name and os.path.exists(file_name): return FileResponse(path=file_name, filename=file_name, media_type='application/octet-stream') return {"message": "No file available"} # ✅ Start FastAPI Server in a Thread