56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
"net/http"
|
||
|
|
||
|
"gitea.voser.cloud/Golang/GoDown/handlers/api"
|
||
|
"gitea.voser.cloud/Golang/GoDown/handlers/sqldb"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
_ "github.com/go-sql-driver/mysql"
|
||
|
)
|
||
|
|
||
|
// Global Variables
|
||
|
var DB *sql.DB
|
||
|
|
||
|
type media struct {
|
||
|
ID string `json: "id"`
|
||
|
YTID string `json: "yt-id"`
|
||
|
Url string `json: "url"`
|
||
|
Localpath string `json: "localpath"`
|
||
|
Size int `json: "size"`
|
||
|
Sha256sum string `json: "sha256sum"`
|
||
|
Length int `json: "length"`
|
||
|
Title string `json: "title"`
|
||
|
Author string `json: "author"`
|
||
|
}
|
||
|
|
||
|
// check error
|
||
|
func check(err error) {
|
||
|
if err != nil {
|
||
|
panic(err.Error())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func get_test_ping(c *gin.Context) {
|
||
|
c.String(http.StatusOK, "pong")
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
sqldb.ReaddbCred()
|
||
|
DB = sqldb.Opendb()
|
||
|
defer DB.Close()
|
||
|
|
||
|
sqldb.Dbinit()
|
||
|
sqldb.Dbentrycount()
|
||
|
|
||
|
router := gin.Default()
|
||
|
router.GET("/api/db", api.GET_api_db)
|
||
|
router.GET("/api/add/:ytid", api.GET_api_add_ytid)
|
||
|
router.GET("/api/get/:ytid", api.GET_api_get_ytid)
|
||
|
//router.GET("/api/download/:ytid", get_api_download_ytid)
|
||
|
router.GET("/test/ping", get_test_ping)
|
||
|
//router.GET("/api/songs", getMedia)
|
||
|
router.Run("127.0.0.1:8000")
|
||
|
}
|