First commit

This commit is contained in:
corrado.mulas
2024-11-19 23:59:40 +01:00
parent 36fa1d9db4
commit 50296df78f
4 changed files with 83 additions and 58 deletions

20
main.go
View File

@@ -8,21 +8,23 @@ import (
"github.com/joho/godotenv"
)
func loadEnv() {
if err := godotenv.Load(); err != nil {
log.Println("No .env file found, using system environment variables")
}
}
func main() {
// Load environment variables
err := godotenv.Load()
if err != nil {
log.Println("No .env file found, using environment variables")
}
loadEnv()
// Register the HTTP handler
http.HandleFunc("/register", RegisterHandler)
http.HandleFunc("/register", registerHandler)
// Start the HTTP server
port := os.Getenv("PORT")
if port == "" {
port = "3000"
port = "3000" // Default to port 3000
}
log.Printf("Server running on port %s\n", port)
log.Printf("Starting server on port %s...", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}