diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1e38c59e5a8b96bc499c361e12c79f7c58850cf6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.8-buster + +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + +COPY auth_key auth_key +COPY deepl_api.py deepl_api.py + +EXPOSE 5000 + +ENTRYPOINT ["python"] +CMD ["deepl_api.py"] diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1be85af956cdf1bb484be00285906fd1834fe530 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# DeepL API +This service receives a string to translate and returns the translation in the desired language. + +This service is part of the [Related Items project](https://gitlab.rrz.uni-hamburg.de/bay1620/wilps-related-items/). + +## Local Setup from repository +Due to the secret AUTH KEY there is no possibility here to use an image from Docker Hub. You have to follow these instructions instead: +- Create a file named 'auth_key' in this folder +- Put your AUTH KEY from DeepL Pro into the file (nothing else) +- Build the Docker image from this folder: `docker build -t deepl-api .` +- Run the Docker container: `docker run -p 6061:5050 deepl-api` + +## Usage +You can use them - for example using curl - as follows: +- `curl -F text="Guten Abend" -F target_lang=EN -X POST http://0.0.0.0:5050/translate` diff --git a/deepl_api.py b/deepl_api.py index 44be8ccb26bde12ec9b8d1b3b04a4dbec8f00d17..d0ddccdb9b4a6b198c31eeb74059f0220de05d71 100644 --- a/deepl_api.py +++ b/deepl_api.py @@ -21,4 +21,4 @@ def get_abstracts_for_query_srf_api(): return get_translation(text, target_lang) app.config['JSON_AS_ASCII'] = False -app.run(host="0.0.0.0", port=int("6061"), debug=True) \ No newline at end of file +app.run(host="0.0.0.0", port=int("5050"), debug=True) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..a50db1c7438703496a830c62e9d2c693fb2e7f09 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +flask