deepl via fastapi
Project description
deepl-fastapi
your own deepl server via fastapi, cross-platform (Windows/Linux/MacOs)
Installation
pip install deepl-fastapi
or (if your use poetry)
poetry add deepl-fastapi
or
pip install git+https://github.com/ffreemt/deepl-fastapi.git
or
- Clone the repo https://github.com/ffreemt/deepl-fastapi.git
git clone https://github.com/ffreemt/deepl-fastapi.git
andcd deepl-fastapi
- `pip install -r requirements.txt
- or
poetry install
- or
Usage
-
(Optional) but recommended: Create a virual environment e.g.,
# Linux and friends python3.7 -m venv .venv source .venv/bin/activate # Windows # py -3.7 -m venv .venv # .venv\Scripts\activate
-
Start the server
deepl-fastapi
# this option is available only if installed via pip install or poetry add
python3.7 -m deepl_fastapi.run_uvicorn
or using uvicorn directly (note the deepl_server
module, not run_uvicorn
)
uvicorn deepl_fastapi.deepl_server:app --reload
or run the server on the external net, for example at port 9888
uvicorn deepl_fastapi.deepl_server:app --reload --host 0.0.0.0 --port 9888
- Explore and consume
Point your browser to http://127.0.0.1:8000/text/?q=test&to_lang=zh
Or in python code (pip install requests
first)
import requests
# get
url = "http://127.0.0.1:8000/text/?q=test me&to_lang=zh"
print(requests.get(url).json())
# {'q': 'test me', 'from_lang': None, 'to_lang': 'zh',
# 'trtext': '考我 试探我 测试我 试探'}
# post
text = "test this and that"
data = {"text": text, "to_lang": "zh"}
resp = requests.post("http://127.0.0.1:8000/text", json=data)
print(resp.json())
# {'q': {'text': 'test this and that', 'from_lang': None, 'to_lang': 'zh', 'description': None},
# 'result': '试探 左右逢源 检验 审时度势'}
Interactice Docs (Swagger UI)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
deepl-fastapi-0.1.0.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for deepl_fastapi-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7c548641008e6ad8aa625a8158d84038b4648bb44e2d7a978108689d1f89913 |
|
MD5 | 7a38a1e81d3e2c6bf76d26bc8a6dd47a |
|
BLAKE2b-256 | eb0bbbbab43cc3f7187bbeddd12dfa838955e71f995d9afd482eb03d6b739f88 |