Compare commits

...
8 Commits
Author SHA1 Message Date
Vincent Young 491a2e7e5e Merge branch 'main' of https://github.com/OwO-Network/DeepLX 2023-04-23 13:25:52 +08:00
Vincent Young c4e7565703 feat: support for specified ports 2023-04-23 13:25:47 +08:00
Vincent Young bbf535e97b chore: switch to the robot release 2023-04-10 00:30:37 +08:00
Vincent Young f9f378e7eb docs: add python call example 2023-03-21 16:56:08 +08:00
Vincent Young d0310450e5 Create .github/FUNDING.yml 2023-03-18 19:05:31 +08:00
Vincent Young 80aaa94b06 Update README.md 2023-03-17 17:27:19 +08:00
Vincent Young 62befe706c docs: add docker compose v2 command
Update README.md
2023-03-17 17:23:41 +08:00
Davy b429e451dd Update README.md 2023-03-17 02:21:15 -07:00
5 changed files with 50 additions and 10 deletions
+1
View File
@@ -0,0 +1 @@
custom: https://paypal.me/missuo
-2
View File
@@ -25,5 +25,3 @@ jobs:
draft: false
files: |
dist/*
env:
GITHUB_TOKEN: ${{ secrets.GT_Token }}
+31 -5
View File
@@ -2,7 +2,7 @@
* @Author: Vincent Young
* @Date: 2022-10-18 07:32:29
* @LastEditors: Vincent Young
* @LastEditTime: 2023-03-16 20:24:59
* @LastEditTime: 2023-04-23 13:25:08
* @FilePath: /DeepLX/README.md
* @Telegram: https://t.me/missuo
*
@@ -12,10 +12,9 @@
Permanently free DeepL API written in Golang
## Description
- `deeplx` in only run in port `1188`, later versions will do the specified port.
- `deeplx` is listening to `0.0.0.0:1188` by default.
- `deeplx` is using `DeepL` Free API.
- `deeplx` is unlimited to the number of requests.
- `DeepLX` is listening to `0.0.0.0:1188` by default. You can modify the listening port by yourself.
- `DeepLX` is using `DeepL` Free API.
- `DeepLX` is unlimited to the number of requests.
## Usage
### Request Parameters
@@ -36,6 +35,13 @@ Permanently free DeepL API written in Golang
"id": 8300079001
}
```
### Specify the port
**Thanks to [cijiugechu](https://github.com/cijiugechu) for [his contribution](https://github.com/OwO-Network/DeepLX/commit/4a0920579ea868b0f05ccdff6bceae316bfd5dc8) to make this feature possible for this project!**
```bash
./deeplx -p 3333
# or
./deeplx -port 3333
```
### Run with Docker
```bash
@@ -51,7 +57,10 @@ docker run -itd -p 1188:1188 missuo/deeplx:latest
mkdir deeplx
cd deeplx
wget https://raw.githubusercontent.com/OwO-Network/DeepLX/main/docker-compose.yaml
# docker compose v1
docker-compose up -d
# or docker compose v2
docker compose up -d
```
### Run on Linux Server
@@ -121,6 +130,23 @@ systemctl enable deeplx
![6a48ba28621f2465028f0](https://missuo.ru/file/6a48ba28621f2465028f0.png)
## Use in Python
```python
import httpx, json
deeplx_api = "http://127.0.0.1:1188/translate"
data = {
"text": "Hello World",
"source_lang": "EN",
"target_lang": "ZH"
}
post_data = json.dumps(data)
r = httpx.post(url = deeplx_api, data = post_data).text
print(r)
```
## Backup the Docker Image of zu1k
```shell
docker run -itd -p 1188:80 missuo/deeplx-bk
+1 -1
View File
@@ -1,4 +1,4 @@
module github.com/OwO-Network/deepl-api
module github.com/OwO-Network/DeepLX
go 1.19
+17 -2
View File
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io"
"log"
@@ -17,7 +18,17 @@ import (
"github.com/tidwall/gjson"
)
var port int
func init() {
const (
defaultPort = 1188
usage = "set up the port to listen on"
)
flag.IntVar(&port, "port", defaultPort, usage)
flag.IntVar(&port, "p", defaultPort, usage)
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
@@ -98,8 +109,11 @@ type ResData struct {
}
func main() {
// parse flags
flag.Parse()
// display information
fmt.Println("DeepL X has been successfully launched! Listening on 0.0.0.0:1188")
fmt.Printf("DeepL X has been successfully launched! Listening on 0.0.0.0:%v\n", port)
fmt.Println("Made by sjlleo and missuo.")
// create a random id
@@ -225,5 +239,6 @@ func main() {
}
}
})
r.Run(":1188") // listen and serve on 0.0.0.0:1188
// by default, listen and serve on 0.0.0.0:1188
r.Run(fmt.Sprintf(":%v", port))
}