File size: 1,476 Bytes
7c956fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""

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)