diff options
author | Jackson Taylor <jtaylor@classicalconversations.com> | 2023-10-02 17:50:59 -0400 |
---|---|---|
committer | Jackson Taylor <jtaylor@classicalconversations.com> | 2023-10-02 17:50:59 -0400 |
commit | 019c5a3466692732f6385965ce435f65a30ce181 (patch) | |
tree | ef3667ff303f76c3ed779f1f9267436836d1c562 |
-rw-r--r-- | audio.mp3 | bin | 0 -> 35520 bytes | |||
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | index.html | 28 | ||||
-rw-r--r-- | main.go | 28 |
4 files changed, 59 insertions, 0 deletions
diff --git a/audio.mp3 b/audio.mp3 Binary files differnew file mode 100644 index 0000000..b2dc4c8 --- /dev/null +++ b/audio.mp3 @@ -0,0 +1,3 @@ +module github.com/JacksonTaylorxyz/clyde_wavesurfer_test + +go 1.21.1 diff --git a/index.html b/index.html new file mode 100644 index 0000000..1a8d1c4 --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>Clyde test</title> + </head> + <body> + <p>Something</p> + <div id="waveform"> + <!-- the waveform will be rendered here --> + </div> + + <script type="module"> + + import WaveSurfer from 'https://unpkg.com/wavesurfer.js@7/dist/wavesurfer.esm.js' + + const wavesurfer = WaveSurfer.create({ + container: '#waveform', + waveColor: '#4F4A85', + progressColor: '#383351', + url: '/audio.mp3', + }) + + wavesurfer.on('interaction', () => { + wavesurfer.play() + }) + </script> + </body> +</html> @@ -0,0 +1,28 @@ +/* +Serve is a very simple static file server in go +Usage: + + -p="8100": port to serve on + -d=".": the directory of static files to host + +Navigating to http://localhost:8100 will display the index.html or directory +listing file. +*/ +package main + +import ( + "flag" + "log" + "net/http" +) + +func main() { + port := flag.String("p", "8100", "port to serve on") + directory := flag.String("d", ".", "the directory of static file to host") + flag.Parse() + + http.Handle("/", http.FileServer(http.Dir(*directory))) + + log.Printf("Serving %s on HTTP port: %s\n", *directory, *port) + log.Fatal(http.ListenAndServe(":"+*port, nil)) +} |