---
# System prepended metadata

title: Dolos Api

---

Dolos Api
===
Github
---
[Dolos官方Github](https://github.com/dodona-edu/dolos)
```bash!
git clone https://github.com/dodona-edu/dolos.git
cd dolos/
```
Docker
---
```bash!
docker-compose pull
docker pull ghcr.io/dodona-edu/dolos-cli:latest
```

### 需要更換成自己IP的
以下程式碼直接複製貼進dolos/web/Dockerfile裡
詳細原因請見
↓ ↓ ↓
[Let dolos-web rebuild if different VITE_API_URL is given](https://github.com/dodona-edu/dolos/blob/c6198940a9bed4eab5778a0da96a9db3141dbdcd/web/Dockerfile)
docker-compose.yml web最後加上
```bash!
command: sh -c "echo -e \"npm run build\\nnpm run preview -- --host 0.0.0.0 --port 8080 --strictPort\" > entrypoint.sh && chmod +x entrypoint.sh && ./entrypoint.sh"
```
```bash!
FROM node:22.8.0-alpine3.19

WORKDIR /web/

ADD public/ /web/public
ADD src/ /web/src
ADD index.html index.d.ts index.js package.json tsconfig.json tsconfig.node.json vite.config.ts /web/

RUN npm install && apk add --no-cache curl

ENV VITE_HOST=0.0.0.0
ENV VITE_PORT=8080
ENV VITE_MODE=server
ENV DEFAULT_VITE_API_URL=http://localhost:3000
EXPOSE 8080/tcp

RUN VITE_API_URL="$DEFAULT_VITE_API_URL" npm run build


CMD (test "$VITE_API_URL" == "$DEFAULT_VITE_API_URL" || npm run build) && npm run preview -- --host "$VITE_HOST" --port "$VITE_PORT" --strictPort
```
基本操作
---
啟動
```bash!
docker-compose up
```
關閉
```bash!
docker-compose down
```
Python
---
用Python爬蟲
```python=
import requests # pip install requests

def submit_to_dolos(name, zipfile_path):
   """
   Submit a ZIP-file to the Dolos API for plagiarism detection
   and return the URL where the resulting HTML report can be found.
   """
   response = requests.post(
      #IP改這行
      'http://localhost:3000/reports',
      files = { 'dataset[zipfile]': open(zipfile_path, 'rb') },
      data = { 'dataset[name]': name }
   )
   json = response.json()
   return json["html_url"]
```

其他問題
---
### 確認api狀態
```html!
http://localhost:3000/up
```