Update main.go
This commit is contained in:
parent
d1df8875cd
commit
b7fec2f897
12
main.go
12
main.go
@ -1,11 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
//"strings"
|
|
||||||
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) {
|
func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -20,7 +22,7 @@ func panel(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func login(w http.ResponseWriter, r *http.Request) {
|
func login(w http.ResponseWriter, r *http.Request) {
|
||||||
Here:
|
//Here:
|
||||||
fmt.Println("method:", r.Method)
|
fmt.Println("method:", r.Method)
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
t, _ := template.ParseFiles("login.gtpl")
|
t, _ := template.ParseFiles("login.gtpl")
|
||||||
@ -48,6 +50,10 @@ Here:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
sql.Register("sqlite3", &SQLiteDriver{})
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", opisStołówkaZPM)
|
http.HandleFunc("/", opisStołówkaZPM)
|
||||||
http.HandleFunc("/login", login)
|
http.HandleFunc("/login", login)
|
||||||
@ -56,5 +62,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("ListenAndServe: ", err)
|
log.Fatal("ListenAndServe: ", err)
|
||||||
}
|
}
|
||||||
|
db, err := sql.Open("sqlite3", "./stolowka.db")
|
||||||
|
checkErr(err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user