veeery basic thing working
This commit is contained in:
parent
f22d11b123
commit
2cacfcbd56
3 changed files with 48 additions and 5 deletions
7
index.html
Executable file
7
index.html
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
<html>
|
||||||
|
<h1>Stream URL</h1>
|
||||||
|
<form action="/stream" method="GET">
|
||||||
|
<label>URL:</label>
|
||||||
|
<input type="text" name="URL" size="100">
|
||||||
|
</form>
|
||||||
|
</html>
|
37
main.go
37
main.go
|
@ -1,16 +1,43 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
func root(w http.ResponseWriter, r *http.Request){
|
// StreamURL Unexported
|
||||||
fmt.Fprint(w, "Root site")
|
type StreamURL struct {
|
||||||
|
URL string
|
||||||
|
}
|
||||||
|
|
||||||
|
func index(w http.ResponseWriter, r *http.Request) {
|
||||||
|
indexTemplate, err := template.ParseFiles(("index.html"))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
indexTemplate.Execute(w, nil)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func stream(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.FormValue("URL") == "" {
|
||||||
|
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||||
|
}
|
||||||
|
streamURL := StreamURL{
|
||||||
|
URL: r.FormValue("URL"),
|
||||||
|
}
|
||||||
|
streamTemplate, err := template.ParseFiles(("stream.html"))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
streamTemplate.Execute(w, streamURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", root)
|
http.HandleFunc("/", index)
|
||||||
|
http.HandleFunc("/stream", stream)
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||||
}
|
}
|
||||||
|
|
9
stream.html
Executable file
9
stream.html
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<img src="{{.URL}}">
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Reference in a new issue