···11+# Port for the server to listen on.
22+# Change this to something you can tunnel during local development
33+PORT=5050
44+55+# Root URL, with protocol, where your server is accessible.
66+PROFILE_URL="http://localhost/"
77+88+ADMIN_USERNAME="change"
99+ADMIN_PASSWORD="me"
1010+1111+JWT_SECRET="bogus"
+18-8
main.go
···2233import (
44 "encoding/json"
55- "flag"
55+ "os"
66 "time"
7788 "log"
···2626)
27272828func main() {
2929- // Setup flags.
3030- portPtr := flag.Int("port", 80, "port to listen on")
3131- addressPtr := flag.String("profile", "http://localhost/", "client URL and front facing address to listen on")
3232- flag.Parse()
2929+ var port int
3030+ if portStr, ok := os.LookupEnv("PORT"); !ok {
3131+ port = 80
3232+ } else {
3333+ portInt, err := strconv.Atoi(portStr)
3434+ if err != nil {
3535+ log.Fatal(err)
3636+ }
33373434- profileURL := *addressPtr
3838+ port = portInt
3939+ }
4040+4141+ profileURL, ok := os.LookupEnv("PROFILE_URL")
4242+ if !ok {
4343+ profileURL = "http://localhost/"
4444+ }
35453646 // Validate the given Client ID before starting the HTTP server.
3747 err := indieauth.IsValidProfileURL(profileURL)
···8494 })
85958696 // Start it!
8787- log.Printf("Listening on http://localhost:%d", *portPtr)
9797+ log.Printf("Listening on http://localhost:%d", port)
8898 log.Printf("Listening on %s", profileURL)
8989- if err := http.ListenAndServe(":"+strconv.Itoa(*portPtr), r); err != nil {
9999+ if err := http.ListenAndServe(":"+strconv.Itoa(port), r); err != nil {
90100 log.Fatal(err)
91101 }
92102}