You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
955 B
43 lines
955 B
package main
|
|
|
|
import (
|
|
"dsAutoCode/Router"
|
|
"dsAutoCode/Utils/CommonUtil"
|
|
"dsAutoCode/Utils/FileUtil"
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
// 显示Logo
|
|
configIniFile := CommonUtil.GetCurrentPath()+"/Config/logo.txt"
|
|
var logo = FileUtil.ReadFileContent(configIniFile)
|
|
fmt.Print(logo)
|
|
|
|
// 开发模式
|
|
gin.SetMode(gin.DebugMode)
|
|
// 开启gin服务器
|
|
r := gin.Default()
|
|
// 常规操作
|
|
r.GET("/", func(c *gin.Context) {
|
|
c.Redirect(http.StatusMovedPermanently, "/Static/index.html")
|
|
})
|
|
//设置静态资源
|
|
r.Static("/Static", CommonUtil.GetCurrentDirectory()+"/Static")
|
|
//主路由
|
|
Router.GinRouter(r)
|
|
//协程启动Firefox
|
|
go startFirefox()
|
|
// 监听并在 0.0.0.0:8888 上启动服务
|
|
r.Run(":8888")
|
|
}
|
|
|
|
func startFirefox(){
|
|
//两秒后打开
|
|
time.Sleep(time.Duration(2)*time.Second)
|
|
//火狐来了~
|
|
CommonUtil.Exec("C:\\Program Files\\Mozilla Firefox\\firefox.exe","http://127.0.0.1:8888")
|
|
}
|