Spaces:
Sleeping
Sleeping
Download main.py from devilseye2004/tester: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/devilseye2004/tester/resolve/main/main.py
- Command line
-
hf download hf://spaces/devilseye2004/tester/main.py
-
curl -L -o main.py https://huggingface.co/spaces/devilseye2004/tester/resolve/main/main.py
1.48 kB
| """ | |
| Main entry point for Hugging Face Spaces deployment | |
| Combines API with root redirect to frontend | |
| """ | |
| from fastapi import FastAPI | |
| from fastapi.responses import RedirectResponse | |
| from fastapi.middleware.cors import CORSMiddleware | |
| import os | |
| # Import our existing app | |
| from app import app as api_app | |
| # Create main app | |
| app = FastAPI(title="Humanizer System API", version="3.0") | |
| # CORS middleware - allow Vercel frontend | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=[ | |
| "https://aquahumanizer.vercel.app", | |
| "http://localhost:3000", # For local development | |
| "*" # For testing | |
| ], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Redirect root to frontend | |
| async def read_root(): | |
| return RedirectResponse(url="https://aquahumanizer.vercel.app") | |
| # Simple info endpoint | |
| async def get_info(): | |
| return { | |
| "name": "Humanizer System API", | |
| "version": "3.0", | |
| "description": "Rule-based text humanization backend", | |
| "frontend": "https://aquahumanizer.vercel.app", | |
| "endpoints": { | |
| "POST /humanize": "Humanize text", | |
| "POST /humanize-document": "Process document files", | |
| "GET /health": "Health check" | |
| } | |
| } | |
| # Mount the API app | |
| app.mount("/", api_app) | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |