-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
40 lines (31 loc) · 836 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
"log"
)
func main() {
engine := html.New("./views", ".html")
app := fiber.New(fiber.Config{Views: engine})
// Use the Static method to serve static files such as images, CSS, and JavaScript.
app.Static("/", "./public")
app.Get("/", func(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{})
})
app.Get("/search", func(c *fiber.Ctx) error {
ticker := c.Query("ticker")
results := SearchTicker(ticker)
return c.Render("results", fiber.Map{
"Results": results,
})
})
app.Get("/news/:ticker", func(c *fiber.Ctx) error {
ticker := c.Params("ticker")
values := SearchTickerNews(ticker)
return c.Render("news", fiber.Map{
"Ticker": ticker,
"News": values,
})
})
log.Fatal(app.Listen(":3000"))
}