tester / main.py
devilseye2004's picture
Upload 10 files
7c956fc verified
Raw History Blame Contribute Delete
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
@app.get("/")
async def read_root():
return RedirectResponse(url="https://aquahumanizer.vercel.app")
# Simple info endpoint
@app.get("/info")
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)