parent
7d259ceef8
commit
8edd16e6ab
2 changed files with 12 additions and 1 deletions
12
server.go
12
server.go
|
@ -173,15 +173,24 @@ func getNew(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
func mytoken(c *fiber.Ctx) error {
|
||||
//if c.Query("error")
|
||||
return c.BodyParser(&SpotifyAPI)
|
||||
}
|
||||
|
||||
func spotifyCallback(c *fiber.Ctx) error {
|
||||
if c.Query("error") != "" {
|
||||
return c.Render("index", fiber.Map{"error": "Erreur lors de la connexion.",})
|
||||
} else {
|
||||
return c.Render("spotify-token", fiber.Map{})
|
||||
}
|
||||
}
|
||||
|
||||
func index(c *fiber.Ctx) error {
|
||||
return c.Render("index", fiber.Map{"connected": !SpotifyAPI.CheckEmpty(),})
|
||||
}
|
||||
|
||||
func main() {
|
||||
//app := fiber.New(fiber.Config(Views: html, ViewsLayout: "layouts/mainbbb"))
|
||||
//app := fiber.New(fiber.Config(Views: html, ViewsLayout: "layouts/main"))
|
||||
app := fiber.New(fiber.Config{Views: html.New("./views", ".html"),})
|
||||
app.Static("/", "./static")
|
||||
|
||||
|
@ -189,6 +198,7 @@ func main() {
|
|||
app.Get("/hello", hello)
|
||||
app.Get("/refresh", getNew)
|
||||
app.Get("/spotify", loginSpotify)
|
||||
app.Get("/callback", spotifyCallback)
|
||||
app.Post("/back", formHandler)
|
||||
app.Post("/mytoken", mytoken)
|
||||
|
||||
|
|
1
views/spotify-token.html
Normal file
1
views/spotify-token.html
Normal file
|
@ -0,0 +1 @@
|
|||
<script src="/gethash.js"></script>
|
Loading…
Reference in a new issue