Skip to content

Commit

Permalink
enable API mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
izuna385 committed Jul 24, 2021
1 parent 199fa89 commit c616d8d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND "noninteractive"
ENV LANG "ja_JP.UTF-8"
ENV PYTHONIOENCODING "utf-8"

RUN apt update -y \
&& apt install -y \
language-pack-ja \
build-essential \
git \
wget \
libmecab-dev \
python3 \
python3-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install -U pip
ARG project_dir=/work/
WORKDIR $project_dir
ADD requirements.txt .
RUN pip install -r requirements.txt
RUN pip install fastapi && pip install uvicorn
RUN python3 -m spacy download ja_core_news_md
COPY . $project_dir

CMD ["uvicorn", "jel.api.server:app", "--reload", "--port", "8000", "--host", "0.0.0.0", "--log-level", "trace"]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ $ pip install jel
$ python -m spacy download ja_core_news_md
```

## Run as API
```
$ docker build -t jel:latest .
$ docker run -d -itd -p 8000:8000 jel

# link
$ curl localhost:8000/api/v1/link -X POST -H "Content-Type: application/json" \
-d '{"sentence": "日本の総理は菅総理だ。"}'

# question
$ curl localhost:8000/api/v1/question -X POST -H "Content-Type: application/json" \
-d '{"sentence": "日本で有名な総理は?"}
```


## Test
`$ python pytest`

Expand Down

0 comments on commit c616d8d

Please sign in to comment.