33 lines
670 B
Go
33 lines
670 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
_ "github.com/mattn/go-sqlite3"
|
|
"lewisdale.dev/oopsie/data"
|
|
"lewisdale.dev/oopsie/ping"
|
|
"lewisdale.dev/oopsie/sites"
|
|
)
|
|
|
|
func main() {
|
|
db := data.Connect("test.sqlite3")
|
|
|
|
db.Exec("PRAGMA foreign_keys = ON;")
|
|
|
|
sites.CreateTable(db)
|
|
ping.CreateTable(db)
|
|
|
|
site := sites.Site{Name: "Lewisdale.dev", Url: "https://lewisdale.dev"}
|
|
site.Save(db)
|
|
|
|
http.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte("This was a GET request!"))
|
|
})
|
|
|
|
http.HandleFunc("POST /", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte("This was a POST request!"))
|
|
})
|
|
|
|
http.ListenAndServe(":8000", nil)
|
|
}
|