From ad5d6aee2df3e7010721d7de85df6400134a4610 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Mon, 24 Jun 2019 17:29:00 -0400 Subject: [PATCH] host everything on heroku --- {api/Godeps => Godeps}/Godeps.json | 0 {api/Godeps => Godeps}/Readme | 0 api/Procfile => Procfile | 0 api/main.go => main.go | 4 +++- {public => static}/favicon.ico | Bin {public => static}/favicon.png | Bin {public => static}/fetch.js | 2 +- {public => static}/index.html | 0 {public => static}/style.css | 0 9 files changed, 4 insertions(+), 2 deletions(-) rename {api/Godeps => Godeps}/Godeps.json (100%) rename {api/Godeps => Godeps}/Readme (100%) rename api/Procfile => Procfile (100%) rename api/main.go => main.go (97%) rename {public => static}/favicon.ico (100%) rename {public => static}/favicon.png (100%) rename {public => static}/fetch.js (96%) rename {public => static}/index.html (100%) rename {public => static}/style.css (100%) diff --git a/api/Godeps/Godeps.json b/Godeps/Godeps.json similarity index 100% rename from api/Godeps/Godeps.json rename to Godeps/Godeps.json diff --git a/api/Godeps/Readme b/Godeps/Readme similarity index 100% rename from api/Godeps/Readme rename to Godeps/Readme diff --git a/api/Procfile b/Procfile similarity index 100% rename from api/Procfile rename to Procfile diff --git a/api/main.go b/main.go similarity index 97% rename from api/main.go rename to main.go index bf7a00f..339c073 100644 --- a/api/main.go +++ b/main.go @@ -149,7 +149,7 @@ func getPlayerNoPixelInformation(id string) (p NoPixelPlayer) { return } -// List handler for Heroku /api/list route +// List handler for now.sh /api/list route func List(w http.ResponseWriter, r *http.Request) { err := loadPlayersJSON() if err != nil { @@ -168,6 +168,8 @@ func main() { addr := ":" + os.Getenv("PORT") http.HandleFunc("/api/list", List) + http.Handle("/", http.FileServer(http.Dir("./static"))) + log.Printf("Listening on %s...\n", addr) if err := http.ListenAndServe(addr, nil); err != nil { panic(err) diff --git a/public/favicon.ico b/static/favicon.ico similarity index 100% rename from public/favicon.ico rename to static/favicon.ico diff --git a/public/favicon.png b/static/favicon.png similarity index 100% rename from public/favicon.png rename to static/favicon.png diff --git a/public/fetch.js b/static/fetch.js similarity index 96% rename from public/fetch.js rename to static/fetch.js index 9c850ef..0c05e19 100644 --- a/public/fetch.js +++ b/static/fetch.js @@ -1,7 +1,7 @@ document.addEventListener("DOMContentLoaded", updateData, false); async function fetchData() { - let request = await fetch("https://hidden-depths-42970.herokuapp.com/api/list"); + let request = await fetch("/api/list"); if(request.status == 200) { console.log("New JSON successfully fetched!"); let data = await request.json(); diff --git a/public/index.html b/static/index.html similarity index 100% rename from public/index.html rename to static/index.html diff --git a/public/style.css b/static/style.css similarity index 100% rename from public/style.css rename to static/style.css