Switch from args to env vars for port and geofeed path

This commit is contained in:
Lily Rose 2025-07-17 18:35:10 +10:00
parent 96341b8367
commit 50cc6fc530
3 changed files with 5 additions and 5 deletions

View file

@ -12,7 +12,7 @@ wisp = ">= 1.8.0 and < 2.0.0"
mist = ">= 5.0.2 and < 6.0.0"
lustre = ">= 5.2.1 and < 6.0.0"
simplifile = ">= 2.3.0 and < 3.0.0"
argv = ">= 1.0.2 and < 2.0.0"
envoy = ">= 1.0.2 and < 2.0.0"
[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"

View file

@ -2,7 +2,6 @@
# You typically do not need to edit this file
packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "directories", version = "1.2.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_stdlib", "platform", "simplifile"], otp_app = "directories", source = "hex", outer_checksum = "D13090CFCDF6759B87217E8DDD73A75903A700148A82C1D33799F333E249BF9E" },
{ name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" },
{ name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" },
@ -31,7 +30,7 @@ packages = [
]
[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
envoy = { version = ">= 1.0.2 and < 2.0.0" }
gleam_erlang = { version = ">= 1.2.0 and < 2.0.0" }
gleam_http = { version = ">= 4.1.0 and < 5.0.0" }
gleam_json = { version = ">= 3.0.2 and < 4.0.0" }

View file

@ -1,4 +1,4 @@
import argv
import envoy
import gleam/dynamic/decode
import gleam/erlang/process
import gleam/http.{Get, Post}
@ -19,7 +19,8 @@ pub fn main() {
let secret_key_base = wisp.random_string(64)
let assert Ok(priv_directory) = wisp.priv_directory("server")
let static_directory = priv_directory <> "/static"
let assert [port_str, geofeed_path, ..] = argv.load().arguments
let assert Ok(port_str) = envoy.get("PORT")
let assert Ok(geofeed_path) = envoy.get("GEOFEED")
let assert Ok(port) = int.parse(port_str)
let assert Ok(_) =
handle_request(static_directory, geofeed_path, _)