Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

## Подготовка к запуску

Скопируйте собранный файл `./dist/torrs` в директорию от куда будет запускаться программа. Далее нужно переписать папку views в тот же каталог.
Скопируйте собранный файл `./dist/torrs` в директорию от куда будет запускаться программа.

### Запуск

Expand Down
16 changes: 12 additions & 4 deletions web/server.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package web

import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"embed"
"html/template"
"log"
"path/filepath"
"strings"
ss "sync"
"time"
"torrsru/db"
"torrsru/global"
"torrsru/web/api"
"torrsru/web/static"

"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)

//go:embed views/*.go.html
var viewFS embed.FS

func Start(port string) {
go db.StartSync()

Expand All @@ -27,7 +32,10 @@ func Start(port string) {
global.Route = gin.New()
global.Route.Use(gin.Recovery(), cors.New(corsCfg), blockUsers())
static.RouteStaticFiles(global.Route)
global.Route.LoadHTMLGlob(filepath.Join(global.PWD, "views/*.go.html"))

tmpl := template.Must(template.ParseFS(viewFS, "views/*.go.html"))
global.Route.SetHTMLTemplate(tmpl)

api.SetRoutes(global.Route)

err := global.Route.Run(":" + port)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.