This commit is contained in:
Brian 2025-04-14 11:28:25 +08:00 committed by GitHub
commit e3bef12518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

15
server.py Normal file
View file

@ -0,0 +1,15 @@
from fastapi import FastAPI, File, UploadFile
import markitdown
app = FastAPI()
@app.post("/convert")
async def convert_to_markdown(file: UploadFile = File(...)):
content = await file.read() # Read the file content
markdown_text = markitdown.convert(content.decode("utf-8")) # Convert to markdown
return {"markdown": markdown_text}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)