Spaces:
Running
Running
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") | |
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") | |
} | |
async def health_check(): | |
"""Health check endpoint""" | |
return {"status": "healthy", "service": "pdf2md", "version": "0.3.0"} | |
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" | |
} | |
async def test_endpoint(): | |
"""Test that new endpoints are available""" | |
return { | |
"message": "New endpoints are working!", | |
"endpoints": ["/api/convert", "/api/test"] | |
} |