mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2025-04-17 13:23:24 +00:00
feat: read port envvar (#53)
Co-authored-by: pan93412 <pan93412@gmail.com>
This commit is contained in:
parent
7bf2bfca21
commit
a2959a01af
13
main.go
13
main.go
@ -9,6 +9,7 @@ import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -130,7 +131,6 @@ func main() {
|
||||
"code": 200,
|
||||
"message": "DeepL Free API, Made by sjlleo and missuo. Go to /translate with POST. http://github.com/OwO-Network/DeepLX",
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
r.POST("/translate", func(c *gin.Context) {
|
||||
@ -250,6 +250,13 @@ func main() {
|
||||
}
|
||||
}
|
||||
})
|
||||
// by default, listen and serve on 0.0.0.0:1188
|
||||
r.Run(fmt.Sprintf(":%v", port))
|
||||
|
||||
envPort, ok := os.LookupEnv("PORT")
|
||||
if ok {
|
||||
r.Run(":" + envPort)
|
||||
} else {
|
||||
// by default, listen and serve on 0.0.0.0:1188
|
||||
r.Run(fmt.Sprintf(":%v", port))
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user