10000 GitHub - cnbeining/DeepLX-Python: Python implementation of https://github.com/OwO-Network/DeepLX
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cnbeining/DeepLX-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepLX-Python

Python implementation of DeepLX, providing a FastAPI-based translation service using DeepL.

This repo only implemented the Free Endpoint.

Features

  • FastAPI-based Async REST API: WSGI version provided for reference
  • Docker and Compose support
  • Token-based authentication
  • Support for both plain text and rich text translation
  • Proxy support via environment variables

Installation

Using Docker (Recommended)

Start with one-liner (Recommended)

docker run -d -p 8000:8000 -e TOKEN=your,tokens,here cnbeining/deeplx-python:latest

Building image yourself

  1. Clone the repository:
git clone https://github.com/cnbeining/DeepLX-Python.git
cd DeepLX-Python
  1. Build and run locally:
docker build -t deeplx-python .
docker run -d -p 8000:8000 -e TOKEN=your,tokens,here deeplx-python

Manual Installation

  1. Clone the repository:
git clone https://github.com/cnbeining/DeepLX-Python.git
cd DeepLX-Python
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the application:
python app/app.py

Configuration

Environment Variables

  • TOKEN: Comma-separated list of valid authentication tokens
  • PROXY: Proxy URL (optional)

Example:

export TOKEN=token1,token2,token3
export PROXY=http://proxy.example.com:8080

API Usage

See DeepLX for details

Authentication

Include your token either as:

  • Query parameter: ?token=your_token
  • Authorization header: Authorization: Bearer your_token or Authorization: DeepL-Auth-Key your_token

Translate Text

curl -X POST "http://localhost:8000/translate" \
-H "Authorization: Bearer your_token" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world!",
"source_lang": "auto",
"target_lang": "es"
}'

Request Parameters

  • text: String or array of strings to translate
  • source_lang: Source language code (default: "auto")
  • target_lang: Target language code (default: "en")
  • tag_handling: Optional parameter for handling HTML/XML tags. Will be automatically detected if not set.

Response Format

{
    "alternatives": ["translated alternatives"],
    "code": 200,
    "data": "translated text",
    "id": 123456,
    "method": "Free",
    "source_lang": "detected_language",
    "target_lang": "target_language"
}

License

This project is licensed under the GNU AGPL 3.0 License - see the LICENSE file for details.

About

Python implementation of https://github.com/OwO-Network/DeepLX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0