mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
Feature: Added config file
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
.vercel
|
||||
*.map
|
||||
config.yml
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# This is required for the API. See https://github.com/Nandaka/PixivUtil2/wiki#pixiv-login-using-cookie
|
||||
# Please keep this carefully, there is a risk of account theft if somebody got your cookie.
|
||||
# It is better to use a decoy account, instead of using your main account's cookie.
|
||||
PHPSESSID:
|
||||
|
||||
userAgent: Mozilla/5.0
|
||||
@@ -0,0 +1,29 @@
|
||||
package configs
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"gopkg.in/yaml.v3"
|
||||
"os"
|
||||
)
|
||||
|
||||
var Config embed.FS
|
||||
var Configs Conf
|
||||
|
||||
type Conf struct {
|
||||
PHPSESSID string `yaml:"PHPSESSID"`
|
||||
userAgent int `yaml:"userAgent"`
|
||||
}
|
||||
|
||||
func (conf *Conf) ReadConfig() {
|
||||
f, err := os.Open("config.yml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
decoder := yaml.NewDecoder(f)
|
||||
err = decoder.Decode(conf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"pixivfe/configs"
|
||||
"pixivfe/views"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -31,6 +32,9 @@ func setupRouter() *gin.Engine {
|
||||
}
|
||||
|
||||
func main() {
|
||||
configs.Configs.ReadConfig()
|
||||
println(configs.Configs.PHPSESSID)
|
||||
|
||||
r := setupRouter()
|
||||
|
||||
r.Run(":8080")
|
||||
|
||||
Reference in New Issue
Block a user