This release is a pre-release and may not be stable for production use.
deepl-fastapi-pw
Your own deepl server via fastapi and playwright, cross-platform (Windows/Linux/MacOs) with API for OmegaT
Installation
- Create a virual environment: optional but recommended
e.g.,
# Linux and friends python3.8 -m venv .venv source .venv/bin/activate # Windows # py -3.8 -m venv .venv # .venv\Scripts\activate
pip install deepl-fastapi-pw
or (if your use poetry)
poetry add deepl-fastapi-pw
or
pip install git+https://github.com/ffreemt/deepl-fastapi-playwright.git
or
- Clone the repo https://github.com/ffreemt/deepl-fastapi-playwright.git
git clone https://github.com/ffreemt/deepl-fastapi-playwright.git
andcd deepl-fastapi-playwright - `pip install -r requirements.txt
- or
poetry install
- or
Usage
- Start the server
python -m deepl_fastapi_pw
Or use uvicorn directly (note the deepl_server module, not run_uvicorn)
uvicorn deepl_fastapi_pw.deepl_server_async:app
or
python -m deepl_fastapi_pw.deepl_server_async
or run the server on the external net, for example at port 9888
uvicorn deepl_fastapi_pw.deepl_server:app --reload --host 0.0.0.0 --port 9888
Explore and consume
Point your browser to http://127.0.0.1:8001/text/?q=test&to_lang=zh
Or in command line:
python -c "import httpx; print(httpx.get('http://127.0.0.1:8001/text/?to_lang=zh&q=test 1\ntest 2').json())"
# output: {'q': 'test 1\ntest 2', 'from_lang': None, 'to_lang': 'zh', 'trtext': '测试 1\n测试 2', 'translation': '测试 1\n测试 2'}
Or in python code (pip install requests first)
import requests
# get
url = "http://127.0.0.1:8001/text/?q=test me&to_lang=zh"
print(requests.get(url).json())
# {'q': 'test me', 'from_lang': None, 'to_lang':
# 'zh', 'trtext': '考我', 'translation': '考我'}
'translation' is there for OmegaT plugin. Refer to the OmegaT Fake MT plugin setup part
in https://github.com/ffreemt/deepl-fastapi
# post
text = "test me \n and him"
data = {"text": text, "to_lang": "zh"}
resp = requests.post("http://127.0.0.1:8001/text", json=data)
print(resp.json())
# {'q': {'text': 'test me \n and him', 'from_lang': None,
# 'to_lang': 'zh', 'description': None}, 'result': '考验我 \n 我和他'}
NB
- Text longer than 1500 characters will be trimmed to 1500. This is what the
deepl.comwebpage can handle (used to be 5000 characters). - The package
deepl-fastapi-pwis in essence a browser from your local IP (although a proxy can be used, refer to get-pwbroser's doc for setting up). Hence if you send too many requests too frequently, your IP may be blocked bydeepl.comtemporarily, which of course will also disabledeepl-fastapi-pw.
Interactive Docs (Swagger UI)
Metadata
Release files for deepl-fastapi-pw 0.1.0a6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deepl_fastapi_pw-0.1.0a6.tar.gz | 11.0 kB | Without provenance | Details for deepl_fastapi_pw-0.1.0a6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deepl_fastapi_pw-0.1.0a6-py3-none-any.whl | Python 3 | none | any | Details for deepl_fastapi_pw-0.1.0a6-py3-none-any.whl |
Total release size: 29.1 kB
Release files / deepl_fastapi_pw-0.1.0a6.tar.gz
| Download URL | deepl_fastapi_pw-0.1.0a6.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c59314708c3fe0ca520306510eb4859e063fb15a4b539d338ec4100a165e09d5
|
|
BLAKE2b-256 checksum How to use checksums |
1ad9858e3ccc0d0d61e10d643e62bfea4bcc31565fd9ada9fc47d2708ce07ef5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.8.10 Windows/10
|
Release files / deepl_fastapi_pw-0.1.0a6-py3-none-any.whl
| Download URL | deepl_fastapi_pw-0.1.0a6-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c24b0b83cd61631bc3241480208cec41553f690aeae6d1b90fbe7b70507a6332
|
|
BLAKE2b-256 checksum How to use checksums |
c699089537cc41eb82033fa20c66d33fa07fe622145dff7cd2ca1620b9864401
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.8.10 Windows/10
|
Security for deepl-fastapi-pw 0.1.0a6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.