Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kevin Lyda
gqgmc
Commits
c4a8662d
Commit
c4a8662d
authored
Feb 01, 2017
by
Kevin Lyda
💬
Browse files
Add some static files.
parent
034506ec
Pipeline
#1225
passed with stage
in 1 minute and 12 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cmd/gqgmcd/main.go
View file @
c4a8662d
...
...
@@ -13,6 +13,7 @@ import (
"log"
"net/http"
"path"
//"sync"
"github.com/prometheus/client_golang/prometheus/promhttp"
"gitlab.com/lyda/gqgmc/devices/geiger"
...
...
@@ -21,7 +22,8 @@ import (
var
addr
=
flag
.
String
(
"listen-address"
,
":8080"
,
"Address for HTTP requests."
)
var
device
=
flag
.
String
(
"device"
,
"/dev/gqgmc"
,
"Device for Geiger Counter."
)
var
model
=
flag
.
String
(
"model"
,
"gqgmc"
,
"Model of Geiger Counter."
)
var
templateDir
=
flag
.
String
(
"template_dir"
,
"templates"
,
"Template directory."
)
var
templateDir
=
flag
.
String
(
"template-dir"
,
"templates"
,
"Template directory."
)
var
staticDir
=
flag
.
String
(
"static-dir"
,
"static"
,
"Static files directory."
)
type
indexPage
struct
{
Model
string
...
...
@@ -44,6 +46,11 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
t
.
Execute
(
w
,
&
indexPg
)
}
func
staticHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
staticFile
:=
path
.
Join
(
*
staticDir
,
path
.
Base
(
r
.
URL
.
Path
))
http
.
ServeFile
(
w
,
r
,
staticFile
)
}
func
main
()
{
flag
.
Parse
()
...
...
@@ -52,6 +59,10 @@ func main() {
indexPg
.
Version
=
gc
.
Version
()
indexPg
.
Serial
=
gc
.
Serial
()
http
.
HandleFunc
(
"/"
,
indexHandler
)
http
.
HandleFunc
(
"/favicon.ico"
,
staticHandler
)
http
.
HandleFunc
(
"/robots.txt"
,
staticHandler
)
http
.
HandleFunc
(
"/humans.txt"
,
staticHandler
)
http
.
Handle
(
"/metrics"
,
promhttp
.
Handler
())
http
.
Handle
(
"/static"
,
http
.
StripPrefix
(
"/static/"
,
http
.
FileServer
(
http
.
Dir
(
*
staticDir
))))
log
.
Fatal
(
http
.
ListenAndServe
(
*
addr
,
nil
))
}
static/favicon.ico
0 → 100644
View file @
c4a8662d
1.12 KB
static/humans.txt
0 → 100644
View file @
c4a8662d
/* TEAM */
TODO
Your title: Your name.
Site: email, link to a contact form, etc.
Twitter: your Twitter username.
Location: City, Country.
/* THANKS */
TODO
/* SITE */
Standards: Let me know if things aren't valid HTML/CSS/JS
Components: Go, Prometheus
Software: Developed using Linux, vim and git.
static/robots.txt
0 → 100644
View file @
c4a8662d
User-Agent: *
Disallow:
Disallow: /metrics
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment