deepl-fastapi


Namedeepl-fastapi JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/ffreemt/deepl-fastapi
Summarydeepl via fastapi
upload_time2023-01-18 06:03:47
maintainer
docs_urlNone
authorfreemt
requires_python>=3.7,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # deepl-fastapi
<!--- repo-name  pypi-name  mod_name func_name --->
[![tests](https://github.com/ffreemt/deepl-fastapi/actions/workflows/routine-tests.yml/badge.svg)][![python](https://img.shields.io/static/v1?label=python+&message=3.7%2B&color=blue)](https://img.shields.io/static/v1?label=python+&message=3.7%2B&color=blue)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![PyPI version](https://badge.fury.io/py/deepl-fastapi.svg)](https://badge.fury.io/py/deepl-fastapi)

Your own deepl server via fastapi, cross-platform (Windows/Linux/MacOs) with API for OmegaT

## Installation
*   Create a virual environment: optional but recommended
    e.g.,
    ```bash
    # Linux and friends
    python3.7 -m venv .venv
    source .venv/bin/activate

    # Windows
    # py -3.7 -m venv .venv
    # .venv\Scripts\activate
    ```

```bash
pip install deepl-fastapi
```
or (if your use poetry)
```bash
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](https://github.com/ffreemt/deepl-fastapi.git)
    ```bash
    git clone https://github.com/ffreemt/deepl-fastapi.git
    ```
    and `cd deepl-fastapi`
*   `pip install -r requirements.txt
    * or ``poetry install``

## Usage

*   Start the server

Use uvicorn directly (note the `deepl_server` module, not `run_uvicorn`)
```bash
uvicorn deepl_fastapi.deepl_server:app
```

or
```bash
deepl-fastapi
# this option is available only if installed via pip install or poetry add
```

or
```bash
python3.7 -m deepl_fastapi.run_uvicorn
```

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](http://127.0.0.1:8000/text/?q=test&to_lang=zh)

Or in python code (`pip install requests` first)
```python
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': '试探 左右逢源 检验 审时度势'}

```

## Interactive Docs (Swagger UI)

 [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)

## OmegaT ``Fake MT`` plugin setup
* Copy ``omegat-plugin-fake-mt-1.0.0.jar`` (available at https://github.com/briacp/omegat-plugin-fake-mt) to OmegaT\plugins (e.g., C:\Program Files\OmegaT\plugins) 

Run``OmegaT``and setup ``omegat-plugin-fake-mt``
```bash
OmegaT/Preferences/Machine Translation/Fake MT/Configure
	Name: Fake Deepl MT
	URL: http://localhost:8000/text
	Source Parameter: from_lang
	Target Parameter: to_lang
	Text Parameter: q
```
![](img/plugin-setup.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ffreemt/deepl-fastapi",
    "name": "deepl-fastapi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "freemt",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/b8/9e/e2fe539d762c0be91d57b3c64df1de14efeb99577ebb61e6ed3bfee94366/deepl-fastapi-0.1.2.tar.gz",
    "platform": null,
    "description": "# deepl-fastapi\n<!--- repo-name  pypi-name  mod_name func_name --->\n[![tests](https://github.com/ffreemt/deepl-fastapi/actions/workflows/routine-tests.yml/badge.svg)][![python](https://img.shields.io/static/v1?label=python+&message=3.7%2B&color=blue)](https://img.shields.io/static/v1?label=python+&message=3.7%2B&color=blue)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![PyPI version](https://badge.fury.io/py/deepl-fastapi.svg)](https://badge.fury.io/py/deepl-fastapi)\n\nYour own deepl server via fastapi, cross-platform (Windows/Linux/MacOs) with API for OmegaT\n\n## Installation\n*   Create a virual environment: optional but recommended\n    e.g.,\n    ```bash\n    # Linux and friends\n    python3.7 -m venv .venv\n    source .venv/bin/activate\n\n    # Windows\n    # py -3.7 -m venv .venv\n    # .venv\\Scripts\\activate\n    ```\n\n```bash\npip install deepl-fastapi\n```\nor (if your use poetry)\n```bash\npoetry add deepl-fastapi\n```\nor\n```\n pip install git+https://github.com/ffreemt/deepl-fastapi.git\n```\nor\n*   Clone the repo [https://github.com/ffreemt/deepl-fastapi.git](https://github.com/ffreemt/deepl-fastapi.git)\n    ```bash\n    git clone https://github.com/ffreemt/deepl-fastapi.git\n    ```\n    and `cd deepl-fastapi`\n*   `pip install -r requirements.txt\n    * or ``poetry install``\n\n## Usage\n\n*   Start the server\n\nUse uvicorn directly (note the `deepl_server` module, not `run_uvicorn`)\n```bash\nuvicorn deepl_fastapi.deepl_server:app\n```\n\nor\n```bash\ndeepl-fastapi\n# this option is available only if installed via pip install or poetry add\n```\n\nor\n```bash\npython3.7 -m deepl_fastapi.run_uvicorn\n```\n\nor run the server on the external net, for example at port 9888\n```\nuvicorn deepl_fastapi.deepl_server:app --reload --host 0.0.0.0 --port 9888\n```\n\n*   Explore and consume\n\nPoint your browser to [http://127.0.0.1:8000/text/?q=test&to_lang=zh](http://127.0.0.1:8000/text/?q=test&to_lang=zh)\n\nOr in python code (`pip install requests` first)\n```python\nimport requests\n\n# get\nurl =  \"http://127.0.0.1:8000/text/?q=test me&to_lang=zh\"\nprint(requests.get(url).json())\n# {'q': 'test me', 'from_lang': None, 'to_lang': 'zh',\n# 'trtext': '\u8003\u6211 \u8bd5\u63a2\u6211 \u6d4b\u8bd5\u6211 \u8bd5\u63a2'}\n\n# post\ntext = \"test this and that\"\ndata = {\"text\": text, \"to_lang\": \"zh\"}\nresp = requests.post(\"http://127.0.0.1:8000/text\", json=data)\nprint(resp.json())\n# {'q': {'text': 'test this and that', 'from_lang': None, 'to_lang': 'zh', 'description': None},\n# 'result': '\u8bd5\u63a2 \u5de6\u53f3\u9022\u6e90 \u68c0\u9a8c \u5ba1\u65f6\u5ea6\u52bf'}\n\n```\n\n## Interactive Docs (Swagger UI)\n\n [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)\n\n## OmegaT ``Fake MT`` plugin setup\n* Copy ``omegat-plugin-fake-mt-1.0.0.jar`` \uff08available at https://github.com/briacp/omegat-plugin-fake-mt\uff09 to OmegaT\\plugins \uff08e.g., C:\\Program Files\\OmegaT\\plugins\uff09 \n\nRun``OmegaT``and setup ``omegat-plugin-fake-mt``\n```bash\nOmegaT/Preferences/Machine Translation/Fake MT/Configure\n\tName: Fake Deepl MT\n\tURL: http://localhost:8000/text\n\tSource Parameter: from_lang\n\tTarget Parameter: to_lang\n\tText Parameter: q\n```\n![](img/plugin-setup.png)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "deepl via fastapi",
    "version": "0.1.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "461b7f7aee7076c8bcb4319d0dfdf99cfb192d0e5078026d4e5d73474c2cbf89",
                "md5": "e97b50471342b852f5fbf3ef52b03bdc",
                "sha256": "005c54fcb0ae6548cdfa0ef73df0af05b50d3390c1279d84b8119a4e19b63f35"
            },
            "downloads": -1,
            "filename": "deepl_fastapi-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e97b50471342b852f5fbf3ef52b03bdc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 8022,
            "upload_time": "2023-01-18T06:03:49",
            "upload_time_iso_8601": "2023-01-18T06:03:49.503460Z",
            "url": "https://files.pythonhosted.org/packages/46/1b/7f7aee7076c8bcb4319d0dfdf99cfb192d0e5078026d4e5d73474c2cbf89/deepl_fastapi-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b89ee2fe539d762c0be91d57b3c64df1de14efeb99577ebb61e6ed3bfee94366",
                "md5": "7bed23e92adbb066e8a20fa110848214",
                "sha256": "a685d1cbb07122939eca08709d13140196ca7b5b128b107a7bde2a02d38c8e4f"
            },
            "downloads": -1,
            "filename": "deepl-fastapi-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7bed23e92adbb066e8a20fa110848214",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 7105,
            "upload_time": "2023-01-18T06:03:47",
            "upload_time_iso_8601": "2023-01-18T06:03:47.360542Z",
            "url": "https://files.pythonhosted.org/packages/b8/9e/e2fe539d762c0be91d57b3c64df1de14efeb99577ebb61e6ed3bfee94366/deepl-fastapi-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-18 06:03:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ffreemt",
    "github_project": "deepl-fastapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "deepl-fastapi"
}
        
Elapsed time: 0.07081s