From bc475daa51931ffda509ebc263d3b273d31807a4 Mon Sep 17 00:00:00 2001 From: zedrickriggins174-glitch <253082006+zedrickriggins174-glitch@users.noreply.github.com> Date: Thu, 19 Mar 2026 05:09:09 -0400 Subject: [PATCH 1/2] Create python-app.yml --- .github/workflows/python-app.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 000000000..1168bd9ad --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,39 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From 795650b819f494373d22a7afaae46a5571f58b3a Mon Sep 17 00:00:00 2001 From: zedrickriggins174-glitch <253082006+zedrickriggins174-glitch@users.noreply.github.com> Date: Sun, 22 Mar 2026 19:14:28 -0400 Subject: [PATCH 2/2] Add FastAPI app entrypoint for Railway deployment --- app.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app.py diff --git a/app.py b/app.py new file mode 100644 index 000000000..64fb4c6a0 --- /dev/null +++ b/app.py @@ -0,0 +1,46 @@ +import os +import tempfile + +from fastapi import FastAPI, File, HTTPException, UploadFile +from fastapi.responses import JSONResponse, PlainTextResponse +from markitdown import MarkItDown + +app = FastAPI(title="markitdown-api") +md = MarkItDown(enable_plugins=False) + + +@app.get("/health") +async def health(): + return {"status": "ok"} + + +@app.post("/convert", response_class=PlainTextResponse) +async def convert(file: UploadFile = File(...)): + filename = file.filename or "upload.bin" + suffix = os.path.splitext(filename)[1] + data = await file.read() + + if not data: + raise HTTPException(status_code=400, detail="Empty file") + + tmp_path = None + try: + with tempfile.NamedTemporaryFile(delete=False, suffix=suffix) as tmp: + tmp.write(data) + tmp_path = tmp.name + + result = md.convert(tmp_path) + return result.text_content + + except Exception as e: + return JSONResponse( + status_code=500, + content={"error": str(e), "filename": filename}, + ) + + finally: + if tmp_path and os.path.exists(tmp_path): + try: + os.remove(tmp_path) + except OSError: + pass