# markitdown-api **Repository Path**: lulihu/markitdown-api ## Basic Information - **Project Name**: markitdown-api - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-26 - **Last Updated**: 2025-03-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # markitdown-api 将文件转为 markdown 字符串 ## 启动 ### 本地启动 ```shell # 拉代码 git clone https://gitee.com/lulihu/markitdown-api.git # 环境配置 cp .env.sample .env # 初始化环境 poetry install # 进入虚拟环境 source .venv/bin/activate # 对于 Windows .venv\Scripts\activate # 启动 python -m uvicorn markitdown_api.app.main:app --reload # 退出环境 deactivate ``` ### 服务器环境 ```shell # 服务器环境安装依赖 apt-get update && apt-get install -y --no-install-recommends ffmpeg exiftool python3 pipx # 安装运行环境 apt-get install python3 curl -sSL https://install.python-poetry.org | python3 - # 拉代码 git clone https://gitee.com/lulihu/markitdown-api.git # 进入项目 cd markitdown-api # 环境配置 cp .env.sample .env # 初始化环境 poetry install # 如果 poetry 不存在在使用命令 ~/.local/bin/poetry install ``` #### 单次启动 ```shell # 进入虚拟环境 source .venv/bin/activate # 启动 gunicorn markitdown_api.app.main:app -w 1 -k uvicorn_worker.UvicornWorker # 退出环境 deactivate ``` #### 使用服务常驻运行 执行 `sudo vim /etc/systemd/system/markitdown-api.service` ```text [Unit] Description=markitdown-api After=network.target [Service] WorkingDirectory=/data/markitdown-api ExecStart=/bin/bash -c "source .venv/bin/activate && gunicorn markitdown_api.app.main:app -w 1 -k uvicorn_worker.UvicornWorker --bind 0.0.0.0:8000" Restart=always [Install] WantedBy=multi-user.target ``` ```shell # 重新加载 systemctl sudo systemctl daemon-reload # 启动服务 sudo systemctl start markitdown-api # 重新启动服务 sudo systemctl restart markitdown-api # 查看状态 sudo systemctl status markitdown-api # 停止服务(会自动重启) sudo systemctl stop markitdown-api # 禁用且停止服务,自动重启失效 sudo systemctl disable --now markitdown-api # 启用且开启服务 sudo systemctl enable --now markitdown-api # 查看日志 journalctl -u markitdown-api.service -f ``` ### 请求 #### 创建任务 ```shell curl --request POST \ --url http://127.0.0.1:8000/api/task \ --header 'content-type: multipart/form-data' \ --form file=@file ``` 响应 ```json { "id": 6 } ``` #### 获取任务详情 ```shell curl --request GET \ --url http://127.0.0.1:8000/api/task/{id} ``` 响应 ```json { "title": "", "content": "xxxx", "status": "SUCCESS", "error_msg": "", "execution_time": 68 } ```