proper-website-2/main.go

81 lines
1.8 KiB
Go
Raw Normal View History

2022-03-01 14:36:04 +01:00
package main
import (
"log"
"net/http"
2022-03-01 15:50:53 +01:00
"git.home.dutchellie.nl/DutchEllie/proper-website-2/components"
2022-03-01 14:36:04 +01:00
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
2022-03-12 15:52:13 +01:00
//type application struct {
// client *mongo.Client
// database *mongo.Database
// collection *mongo.Collection
//}
const (
apiurl = "https://quenten.nl:8007/"
)
2022-03-02 13:38:28 +01:00
2022-03-01 14:36:04 +01:00
func main() {
2022-03-01 15:50:53 +01:00
homepage := components.NewHomepage()
2022-03-01 17:07:33 +01:00
aboutpage := components.NewAboutPage()
2022-03-07 13:05:33 +01:00
friendspage := components.NewFriendsPage()
2022-03-01 15:50:53 +01:00
app.Route("/", homepage)
2022-03-01 17:07:33 +01:00
app.Route("/about", aboutpage)
2022-03-07 13:05:33 +01:00
app.Route("/friends", friendspage)
2022-03-01 14:36:04 +01:00
2022-03-01 15:50:53 +01:00
// This is executed on the client side only.
// It handles client side stuff
// It exits immediately on the server side
2022-03-01 14:36:04 +01:00
app.RunWhenOnBrowser()
2022-03-12 15:52:13 +01:00
handler := &app.Handler{
2022-03-01 14:51:45 +01:00
Name: "Internetica Galactica",
Description: "A 1990's style PWA!",
2022-03-01 15:50:53 +01:00
Styles: []string{
"/web/static/style.css",
2022-03-01 19:45:23 +01:00
"/web/static/adreena.css",
2022-03-01 15:50:53 +01:00
"/web/static/anisha.css",
2022-03-01 19:45:23 +01:00
"/web/static/havakana.css",
2022-03-01 15:50:53 +01:00
},
2022-03-01 19:45:23 +01:00
CacheableResources: []string{},
2022-03-12 15:52:13 +01:00
}
app.GenerateStaticWebsite("./staticsite", handler)
/*
uri := "mongodb+srv://guestbook-database:5WUDzpvBKBBiiMCy@cluster0.wtt64.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
if err != nil {
fmt.Println(err)
return
}
defer func() {
if err = client.Disconnect(context.TODO()); err != nil {
panic(err)
}
}()
// Ping the primary
if err := client.Ping(context.TODO(), readpref.Primary()); err != nil {
panic(err)
}
db := client.Database("guestbook")
coll := db.Collection("comments")
apiapp := &application{
client: client,
database: db,
collection: coll,
}
*/
http.Handle("/", handler)
//http.HandleFunc("/api/comment", apiapp.Comment)
2022-03-01 14:36:04 +01:00
if err := http.ListenAndServe(":8000", nil); err != nil {
log.Fatal(err)
}
}