summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go33
1 files changed, 6 insertions, 27 deletions
diff --git a/main.go b/main.go
index b10de22..6abaa13 100644
--- a/main.go
+++ b/main.go
@@ -4,7 +4,6 @@ import (
"fmt"
"http"
"exp/template"
- mysql "github.com/Philio/GoMySQL"
"os"
"json"
"strconv"
@@ -22,10 +21,9 @@ type Playlist struct {
var templates map[string]*template.Template
const debug = true
-var db *mysql.Client
func home(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "path is %s", r.URL.Path[1:])
+ fmt.Fprintf(w, "Welcome to Audio Axis!")
}
func playlist(w http.ResponseWriter, r *http.Request) {
@@ -171,21 +169,9 @@ func poll(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
timestamp := q.Get("timestamp")
if timestamp == "0" {
- query, err := db.Prepare("SELECT `yid`,`title`,`user` FROM `playlist` JOIN `song` WHERE `id` = ? ORDER BY `order` ASC")
- if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
- return
- }
- err = query.BindParams(q.Get("pid"))
- if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
- return
- }
- err = query.Execute()
- if err != nil {
- http.Error(w, err.String(), http.StatusInternalServerError)
- return
- }
+ query, err := prepare(
+ "SELECT `yid`,`title`,`user` FROM `playlist` JOIN `song` WHERE `id` = ? ORDER BY `order` ASC",
+ q.Get("pid"))
updates := make([]Update, 0, 2)
for {
@@ -254,14 +240,7 @@ func main() {
templates[path] = t
}
- var err os.Error
- //db, err = mysql.DialTCP("raylu.net", "audio", "audio", "audio")
- db, err = mysql.DialTCP("173.228.31.111", "audio", "audio", "audio")
- if err != nil {
- fmt.Println(err)
- os.Exit(1)
- }
- db.Reconnect = true
+ initDb()
http.HandleFunc("/", home)
http.HandleFunc("/p/", playlist)
@@ -269,7 +248,7 @@ func main() {
http.HandleFunc("/remove/", remove)
http.HandleFunc("/move/", move)
http.HandleFunc("/poll/", poll)
- err = http.ListenAndServe("localhost:8000", nil)
+ err := http.ListenAndServe("localhost:8000", nil)
if err != nil {
fmt.Println(err)
os.Exit(1)