Skip to main content

deepl via fastapi using deepl-scraper-pw

Project description

deepl-fastapi-pw

[tests]pythonCode style: blackLicense: MITPyPI version

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.7 -m venv .venv
    source .venv/bin/activate
    
    # Windows
    # py -3.7 -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

Usage

  • Start the server

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 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': '考我 试探我 测试我 试探'}

# post
text = "test this and that"
data = {"text": text, "to_lang": "zh"}
resp = requests.post("http://127.0.0.1:8001/text", json=data)
print(resp.json())
# {'q': {'text': 'test this and that', 'from_lang': None, 'to_lang': 'zh', 'description': None},
# 'result': '试探 左右逢源 检验 审时度势'}

Interactive Docs (Swagger UI)

http://127.0.0.1:8000/docs

Project details


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-pw-0.1.0a1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepl_fastapi_pw-0.1.0a1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file deepl-fastapi-pw-0.1.0a1.tar.gz.

File metadata

  • Download URL: deepl-fastapi-pw-0.1.0a1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.8.10 Windows/10

File hashes

Hashes for deepl-fastapi-pw-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 5194f36b9fd7e72dbe4e88ce24f27ed6a3f4eab8f9fd88ebf6ad8f2b04b968f7
MD5 cc049cfd4506a04ebc48cad4ad49f568
BLAKE2b-256 033e596aef09e5bdd5dd2212d06a819947d6b8ee91a7d9db19fa01a251f3abf3

See more details on using hashes here.

File details

Details for the file deepl_fastapi_pw-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for deepl_fastapi_pw-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 d325aa7088dbb1dc59e89800e36febbceaa89fe5d667c629f09cc29a8a4096c6
MD5 e09cf798155291e97feb621b16531a94
BLAKE2b-256 0e4738cc474a17fd8fd33e8d0466f095c61593c33800282db930df6eb0a5c902

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page