-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
68 lines (54 loc) · 1.29 KB
/
main.go
File metadata and controls
68 lines (54 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"database/sql"
"html/template"
"log"
"net/http"
"os"
_ "github.com/mattn/go-sqlite3"
"github.com/zserge/lorca"
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
t := template.Must(template.ParseFiles("index.html"))
err := t.Execute(w, nil)
if err != nil {
log.Fatal(err)
return
}
}
func httpServe() {
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("./css"))))
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("./public"))))
http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("./js"))))
http.HandleFunc("/", indexHandler)
http.ListenAndServe(":8888", nil)
}
func main() {
os.Remove("./screen.db")
db, err := sql.Open("sqlite3", "./screen.db")
if err != nil {
log.Fatal(err)
}
defer db.Close()
sqlStmt := `
create table foo (id integer not null primary key, name text);
delete from foo;
`
_, err = db.Exec(sqlStmt)
if err != nil {
log.Printf("%q: %s\n", err, sqlStmt)
return
}
go httpServe()
ui, err := lorca.New("", "", 480, 320)
if err != nil {
log.Fatal(err)
}
bounds := new(lorca.Bounds)
bounds.WindowState = "fullscreen"
ui.SetBounds(*bounds)
ui.Load("http://localhost:8888")
defer ui.Close()
// Wait until UI window is closed
<-ui.Done()
}