mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-12-01 23:07:51 +00:00
Compare commits
6
Commits
23693936cf
..
v0.8.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41bba5e89f | ||
|
|
e286a732cb | ||
|
|
6db098eb8b | ||
|
|
fab55bfefa | ||
|
|
2055f022dc | ||
|
|
b85bb324e2 |
@@ -9,7 +9,7 @@ jobs:
|
|||||||
|
|
||||||
Build:
|
Build:
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
runs-on: self-hosted
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
### Custom Options
|
### Custom Options
|
||||||
**The following settings are optional and not required.**
|
**The following settings are optional and not required.**
|
||||||
- `-port` or `-p` : Listening port. Default is `1188`.
|
- `-port` or `-p` : Listening port. Default is `1188`.
|
||||||
- `-token` : Access token. If you have set it up, each request will need to include an `Authorization` header.
|
- `-token` : Access token. If you have set it up, each request needs to include `Authorization` in the **Headers** or `token` parameter in the **URL Params**.
|
||||||
- `-authkey` : DeepL Official `AuthKey`. If you have set it up, after the 429 response, the official AuthKey will be used for the request. If multiple authKeys are used simultaneously, they need to be separated by commas.
|
- `-authkey` : DeepL Official `AuthKey`. If you have set it up, after the 429 response, the official AuthKey will be used for the request. If multiple authKeys are used simultaneously, they need to be separated by commas.
|
||||||
|
|
||||||
#### Requesting a token-protected **DeepLX API** instance using the `curl`
|
#### Requesting a token-protected **DeepLX API** instance using the `curl`
|
||||||
@@ -81,6 +81,16 @@ curl -X POST http://localhost:1188/translate \
|
|||||||
"target_lang": "DE"
|
"target_lang": "DE"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
or
|
||||||
|
```
|
||||||
|
curl -X POST http://localhost:1188/translate?token=your_access_token \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"text": "Hello, world!",
|
||||||
|
"source_lang": "EN",
|
||||||
|
"target_lang": "DE"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
### Run with Docker
|
### Run with Docker
|
||||||
```bash
|
```bash
|
||||||
@@ -160,9 +170,10 @@ After installation, start the daemon with the following command.
|
|||||||
```bash
|
```bash
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable deeplx
|
systemctl enable deeplx
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Special thanks to [AsukaMinato](https://github.com/asukaminato0721) for maintaining the updates of [ArchLinux packages](https://aur.archlinux.org/packages/deeplx-bin).**
|
||||||
|
|
||||||
### Run on Sealos
|
### Run on Sealos
|
||||||
|
|
||||||
[](https://cloud.sealos.io/?openapp=system-template%3FtemplateName%3Ddeeplx)
|
[](https://cloud.sealos.io/?openapp=system-template%3FtemplateName%3Ddeeplx)
|
||||||
@@ -171,7 +182,7 @@ systemctl enable deeplx
|
|||||||
1. Install [bob-plugin-deeplx](https://github.com/missuo/bob-plugin-deeplx) on Bob.
|
1. Install [bob-plugin-deeplx](https://github.com/missuo/bob-plugin-deeplx) on Bob.
|
||||||
|
|
||||||
2. Setup the API. (If you use Brew to install locally you can skip this step)
|
2. Setup the API. (If you use Brew to install locally you can skip this step)
|
||||||

|

|
||||||
|
|
||||||
## Setup on [immersive-translate](https://github.com/immersive-translate/immersive-translate)
|
## Setup on [immersive-translate](https://github.com/immersive-translate/immersive-translate)
|
||||||
**It is not recommended, because the `immersive-translate` will send many requests in a short time, which will cause the `DeepL API` to block your IP.**
|
**It is not recommended, because the `immersive-translate` will send many requests in a short time, which will cause the `DeepL API` to block your IP.**
|
||||||
@@ -182,7 +193,7 @@ systemctl enable deeplx
|
|||||||
|
|
||||||
3. Set the URL. (If you are not deploying locally, you need to change 127.0.0.1 to the IP of your server)
|
3. Set the URL. (If you are not deploying locally, you need to change 127.0.0.1 to the IP of your server)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Use in Python
|
## Use in Python
|
||||||
```python
|
```python
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 287 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 592 KiB |
@@ -274,8 +274,9 @@ func main() {
|
|||||||
c.BindJSON(&req)
|
c.BindJSON(&req)
|
||||||
|
|
||||||
if cfg.Token != "" {
|
if cfg.Token != "" {
|
||||||
providedToken := c.GetHeader("Authorization")
|
providedTokenInQuery := c.Query("token")
|
||||||
if providedToken != "Bearer "+cfg.Token {
|
providedTokenInHeader := c.GetHeader("Authorization")
|
||||||
|
if providedTokenInHeader != "Bearer "+cfg.Token && providedTokenInQuery != cfg.Token {
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{
|
c.JSON(http.StatusUnauthorized, gin.H{
|
||||||
"code": http.StatusUnauthorized,
|
"code": http.StatusUnauthorized,
|
||||||
"message": "Invalid access token",
|
"message": "Invalid access token",
|
||||||
|
|||||||
Reference in New Issue
Block a user