mineru2 / main.py
marcosremar2's picture
Rename app.py to main.py to force complete rebuild
8c5af8c
from fastapi import FastAPI, File, UploadFile, HTTPException
from fastapi.responses import HTMLResponse, JSONResponse
import os
app = FastAPI(title="MinerU PDF Converter", version="0.3.0")
@app.get("/")
async def root():
"""Simple hello world endpoint"""
return {
"message": "Hello World from MinerU PDF Converter!",
"status": "running",
"version": "0.3.0",
"environment": os.environ.get("SPACE_ID", "local")
}
@app.get("/health")
async def health_check():
"""Health check endpoint"""
return {"status": "healthy", "service": "pdf2md", "version": "0.3.0"}
@app.post("/api/convert")
async def convert_pdf(file: UploadFile = File(...)):
"""Test PDF upload endpoint"""
if not file.filename.endswith('.pdf'):
raise HTTPException(status_code=400, detail="Only PDF files are supported")
return {
"message": "PDF upload endpoint is working!",
"filename": file.filename,
"size": len(await file.read()),
"status": "test_mode"
}
@app.get("/api/test")
async def test_endpoint():
"""Test that new endpoints are available"""
return {
"message": "New endpoints are working!",
"endpoints": ["/api/convert", "/api/test"]
}