After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 84 KiB |
@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed images/*
|
||||
var content embed.FS
|
||||
|
||||
const Port = "9000"
|
||||
const APIVersion = "1.0"
|
||||
const shortForm = "2006-Jan-02"
|
||||
|
||||
type App struct {
|
||||
Day string
|
||||
ImgageURL string
|
||||
}
|
||||
|
||||
func updateData(a *App) {
|
||||
}
|
||||
|
||||
func return_json(w http.ResponseWriter, r *http.Request) {
|
||||
jsonB := make(map[string]string)
|
||||
jsonB["date"] = "Today's date!"
|
||||
jsonB["picture"] = "dummy!"
|
||||
jsonB["api-version"] = APIVersion
|
||||
jsonF, error := json.Marshal(jsonB)
|
||||
|
||||
if error == nil {
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte("Error constructing json!"))
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(200)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(jsonF)
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("Running Bingus API version "+APIVersion,
|
||||
"\nReport any problems to your local Bingus chatper.",
|
||||
"\nSpinning up server on PORT: "+Port)
|
||||
//http.Handle("/", http.StripPrefix("/", http.FileServer(http.FS(content))))
|
||||
http.HandleFunc("/", return_json)
|
||||
log.Fatal(http.ListenAndServe(":"+Port, nil))
|
||||
}
|