added static files and moved templates to own dir
This commit is contained in:
parent
343d9c7cee
commit
e1fcf85910
5 changed files with 9 additions and 3 deletions
8
main.go
8
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
|
@ -12,7 +13,7 @@ type StreamURL struct {
|
|||
}
|
||||
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
indexTemplate, err := template.ParseFiles(("index.html"))
|
||||
indexTemplate, err := template.ParseFiles(filepath.Join("templates", "index.html"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -27,7 +28,7 @@ func stream(w http.ResponseWriter, r *http.Request) {
|
|||
streamURL := StreamURL{
|
||||
URL: r.FormValue("URL"),
|
||||
}
|
||||
streamTemplate, err := template.ParseFiles(("stream.html"))
|
||||
streamTemplate, err := template.ParseFiles(filepath.Join("templates", "stream.html"))
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -37,6 +38,9 @@ func stream(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
staticFileServer := http.FileServer(http.Dir("./static"))
|
||||
http.Handle("/static/", http.StripPrefix("/static/", staticFileServer))
|
||||
|
||||
http.HandleFunc("/", index)
|
||||
http.HandleFunc("/stream", stream)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
|
|
1
static/js/stream.js
Executable file
1
static/js/stream.js
Executable file
|
@ -0,0 +1 @@
|
|||
alert("test");
|
|
@ -1,6 +1,6 @@
|
|||
<html>
|
||||
<head>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
1
tmp/air_errors.log
Normal file
1
tmp/air_errors.log
Normal file
|
@ -0,0 +1 @@
|
|||
exit status 2exit status 2exit status 2exit status 2
|
Loading…
Add table
Reference in a new issue