33 lines
588 B
Go
33 lines
588 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"io"
|
||
|
"net/http"
|
||
|
"tmp/internal/database"
|
||
|
|
||
|
_ "github.com/mattn/go-sqlite3"
|
||
|
)
|
||
|
|
||
|
// This is what a handler looks like
|
||
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||
|
fmt.Println("Request received")
|
||
|
io.WriteString(w, "This is my website!\n")
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
println("Starting server...")
|
||
|
database.DbConnect()
|
||
|
|
||
|
// Mounting the handler
|
||
|
fs := http.FileServer(http.Dir("static"))
|
||
|
http.Handle("/", fs)
|
||
|
http.HandleFunc("/hello", handler)
|
||
|
|
||
|
// Start the server on port 8080
|
||
|
err := http.ListenAndServe(":8080", nil)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|