File size: 1,251 Bytes
39baca3
 
2f87aed
 
39baca3
2f87aed
 
 
 
 
 
 
39baca3
2f87aed
 
 
 
 
 
39baca3
550ec39
 
39baca3
 
550ec39
 
 
 
39baca3
 
 
 
550ec39
 
39baca3
 
 
 
 
 
 
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
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"]
    }