Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
feat(server): add web server
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer committed Nov 24, 2021
1 parent 9925fd3 commit da01b93
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Setup

1. Clone this repo
2. Configure and make your stuff in `index.js`
3. Open the file `index.html` in chromium browser and start record
1. Download last release
2. Extract the downloaded file
3. (*optional*) Configure and make your stuff in `static/index.js`
4. Run `squirelo-voice-recognition.exe` (*__note__: you can change the port, eg. `--listen-addr :5000`*)
5. Go to `http://localhost:5000`
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/orblazer/squirelo-voice-recognition

go 1.17
23 changes: 23 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"flag"
"log"
"net/http"
)

var listenAddr string

func main() {
flag.StringVar(&listenAddr, "listen-addr", ":5000", "server listen address")
flag.Parse()

fs := http.FileServer(http.Dir("./static"))
http.Handle("/", fs)

log.Printf("Listening on %s...", listenAddr)
err := http.ListenAndServe(listenAddr, nil)
if err != nil {
log.Fatal(err)
}
}
File renamed without changes.
6 changes: 3 additions & 3 deletions index.html → static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<meta charset="utf-8" />
<title>Squirelo - tic de langage</title>
<script src="./GrammarDetector.js"></script>
<script src="./setup.js"></script>
<script src="./index.js"></script>
<script src="/GrammarDetector.js"></script>
<script src="/setup.js"></script>
<script src="/index.js"></script>

<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit da01b93

Please sign in to comment.