Update main.go

This commit is contained in:
s441433 2018-12-29 04:54:47 +01:00
parent 51b02276b8
commit c1099e75c6

19
main.go
View File

@ -7,6 +7,8 @@ import (
"log" "log"
"net/http" "net/http"
//"time"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
) )
@ -20,9 +22,10 @@ func opisStołówkaZPM(w http.ResponseWriter, r *http.Request) {
} }
func panel(w http.ResponseWriter, r *http.Request) { func panel(w http.ResponseWriter, r *http.Request) {
fmt.Println("method:", r.Method) //time.Sleep(3 * time.Second)
t, _ := template.ParseFiles("panel.gtpl") //fmt.Println("method:", r.Method)
t.Execute(w, nil) //t, _ := template.ParseFiles("panel.gtpl")
//t.Execute(w, nil)
//*************************************************************************** //***************************************************************************
db, err := sql.Open("sqlite3", "stolowkaZPM.db") db, err := sql.Open("sqlite3", "stolowkaZPM.db")
@ -35,16 +38,12 @@ func panel(w http.ResponseWriter, r *http.Request) {
var Password string var Password string
var PIN int var PIN int
var RFID int var RFID int
fmt.Fprintf(w, "Lista użytkowników:\n")
for rows.Next() { for rows.Next() {
err = rows.Scan(&IDusers, &User, &Password, &PIN, &RFID) err = rows.Scan(&IDusers, &User, &Password, &PIN, &RFID)
checkErr(err) checkErr(err)
fmt.Printf("%d. %s, %s, %d, %d \n", IDusers, User, Password, PIN, RFID) fmt.Printf("%d. %s, %s, %d, %d \n", IDusers, User, Password, PIN, RFID)
fmt.Fprint(w, IDusers) fmt.Fprintf(w, "%d. %s \n", IDusers, User)
fmt.Fprint(w, ". ")
fmt.Fprint(w, User)
fmt.Fprint(w, " \n")
} }
rows.Close() rows.Close()
db.Close() db.Close()
@ -97,7 +96,7 @@ func login(w http.ResponseWriter, r *http.Request) {
if Password == passwordFROMsite { if Password == passwordFROMsite {
fmt.Fprintln(w, zaloguj) fmt.Fprintln(w, zaloguj)
fmt.Fprintln(w, usernameFROMsite) fmt.Fprintln(w, usernameFROMsite)
fmt.Fprintln(w, passwordFROMsite) //panel(w, r)
break break
} }
} }