From cb0bdf9028b6952fe4bb1889973091b4ec4c896a Mon Sep 17 00:00:00 2001
From: pan93412 <pan93412@gmail.com>
Date: Sun, 9 Apr 2023 16:54:56 +0800
Subject: [PATCH] feat: Read PORT envvar

---
 main.go | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go
index 030b540..f333182 100644
--- a/main.go
+++ b/main.go
@@ -8,6 +8,7 @@ import (
 	"log"
 	"math/rand"
 	"net/http"
+	"os"
 	"strings"
 	"time"
 
@@ -115,7 +116,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) {
@@ -225,5 +225,11 @@ func main() {
 			}
 		}
 	})
-	r.Run(":1188") // listen and serve on 0.0.0.0:1188
+
+	port, ok := os.LookupEnv("PORT")
+	if ok {
+		r.Run(":" + port)
+	} else {
+		r.Run(":1188") // listen and serve on 0.0.0.0:1188
+	}
 }