diff options
| author | Thomas Grothe <grothe.tr@gmail.com> | 2026-02-22 21:18:22 -0500 |
|---|---|---|
| committer | Thomas Grothe <grothe.tr@gmail.com> | 2026-02-22 21:18:22 -0500 |
| commit | f3d75ecf1e6006b2ab669a37dd73a5c7b03c4739 (patch) | |
| tree | 95ecc5d2e3ca919b312f6ae57ae4e7695e369b95 /main.go | |
| parent | 790f62dd2a54fb954a64304392d74a087cb45698 (diff) | |
cool toy with 3D graph CRDT
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/main.go b/main.go deleted file mode 100644 index 80a3583..0000000 --- a/main.go +++ /dev/null @@ -1,81 +0,0 @@ -package main - -import ( - "encoding/json" - "flag" - "fmt" - "log" - "net/http" - "os" -) - -// Configuration for the server -type Config struct { - Debug bool - Port int -} - -// Environment variables to pass to frontend -type EnvVars struct { - Thing int `json:"thing"` - // Add more environment variables as needed -} - -// Get environment variables to pass to frontend -func getEnvVars() EnvVars { - return EnvVars{ - Thing: 1, - // Add more variables as needed - } -} - -func main() { - // Parse command line flags - config := Config{} - flag.IntVar(&config.Port, "port", 5000, "Port to run the server on") - flag.BoolVar(&config.Debug, "debug", true, "Enable debug mode") - flag.Parse() - - // Override port from environment variable if set - if portStr := os.Getenv("PORT"); portStr != "" { - var err error - config.Port, err = fmt.Sscanf(portStr, "%d", &config.Port) - if err != nil { - log.Printf("Warning: Invalid PORT environment variable: %s. Using default port %d", portStr, config.Port) - } - } - - // Create a file server for static files - fs := http.FileServer(http.Dir(".")) - - // Set up routes - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - // If the request is for the root path, serve index.html - if r.URL.Path == "/" { - http.ServeFile(w, r, "index.html") - return - } - // Otherwise, use the file server to serve static files - fs.ServeHTTP(w, r) - }) - - // API routes - http.HandleFunc("/api/env", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(getEnvVars()) - }) - - http.HandleFunc("/api/health", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(map[string]string{"status": "ok"}) - }) - - // Error handlers are handled by default Go error handling - - // Start the server - addr := fmt.Sprintf(":%d", config.Port) - log.Printf("Starting server at http://localhost%s", addr) - if err := http.ListenAndServe(addr, nil); err != nil { - log.Fatalf("Server error: %v", err) - } -} |
