This repository has been archived by the owner on Nov 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4273184
commit 4a5fbc0
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"path" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/kenellorando/clog" | ||
) | ||
|
||
func main() { | ||
// Handle routes | ||
r := mux.NewRouter() | ||
|
||
// | ||
r.PathPrefix("/css/").Handler(http.StripPrefix("/css/", http.FileServer(http.Dir("./public/css/")))) | ||
r.PathPrefix("/js/").Handler(http.StripPrefix("/js/", http.FileServer(http.Dir("./public/js/")))) | ||
r.HandleFunc("/", ServeRoot).Methods("GET") | ||
|
||
// Start server | ||
clog.Info("main", fmt.Sprintf("Starting webserver on port <%s>.", ":8900")) | ||
clog.Fatal("main", "Server failed to start!", http.ListenAndServe(":8900", r)) | ||
} | ||
|
||
// ServeRoot - serve the homepage | ||
func ServeRoot(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Content-type", "text/html") | ||
http.ServeFile(w, r, path.Dir("./public/index.html")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>Melody</title> | ||
|
||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> | ||
<script type="text/javascript"> | ||
$(document).ready(function () { | ||
setTimeout(function () {getReport();}, 0); | ||
setInterval(function () {getReport();}, 1000) | ||
}) | ||
|
||
function getReport() { | ||
$.ajax({ | ||
type: 'GET', | ||
url: 'https://api.melody.systems/api/v0.1/getreport', | ||
success: function(data) { | ||
console.log(data); | ||
document.getElementById("rawoutput").innerHTML = data; | ||
} | ||
}) | ||
} | ||
|
||
</script> | ||
</head> | ||
<body> | ||
<h1>Melody</h1> | ||
<p>Systems Infrastructure Monitor</p> | ||
|
||
<div id="rawoutput"></div> | ||
</body> | ||
</html> |