fyp/main.go

38 lines
622 B
Go

package main
import (
"fmt"
"database/sql"
_ "github.com/lib/pq"
)
const (
host = "localhost"
port = 5432
user = "postgres"
password = "verysafepassword"
dbname = "aistuff"
)
func main() {
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
"password=%s dbname=%s sslmode=disable",
host, port, user, password, dbname)
db, err := sql.Open("postgres", psqlInfo)
if err != nil {
panic(err)
}
defer db.Close()
fmt.Println("Starting server on :8000!")
handle := NewHandler(db)
handle.GetHTML("/", AnswerTemplate("index.html", nil))
usersEndpints(db, handle)
handle.Startup()
}