I need to modify basic webserver so that it can take arguments or configuration on startup. I was just wondering if anyone has any thoughts on this?
The easiest thing is to just make command line arguments as required.
But I was wondering if there are other options we might want to consider?
Specifically I think I need to be able to listen to 0.0.0.0 instead of just localhost for use within a Docker container.
I was trying to use a different port with basic-webserver yesterday, would be nice to have some way to configure it :+1:
Probably should be a config file or environment variable
I think probably the best path here is too finally make it possible to request multiple functions from the app, and also to allow exposing multiple functions to the host
Cause you would want to change it based on CI vs prod without changing any roc code
I think we could do that for now to unblock, but in general I definitely think platforms should not depend on env vars
rather, they should explicitly ask the app for all config, and if the app wants to use env vars to configure their own config, that's up to them
e.g. in addition to main, apps also are asked to expose init : EnvVars -> Config or something like that
and the server calls that once on startup
and Config includes things like port etc
I could probably hack that into the main API, and still keep the mainForHost API unchanged. I could hardcode a "Request" and "Response" for doing that, and expose an additional init to the application.
We could clean it up later and update the mainForHost part to have multiple functions exposes to the host
So apps won't need to change in the future, and we don't have the platform relying on an ENV Var. Just the host<->platform part of the API is a little more complicated than required.
It's probably too hacky I think
Oh, they already are Evironment variables... I only just realised.
$ ROC_BASIC_WEBSERVER_HOST=0.0.0.0 ROC_BASIC_WEBSERVER_PORT=9090 roc examples/hello-web.roc
🔨 Rebuilding platform...
Listening on <http://0.0.0.0:9090>
Last updated: Jun 16 2026 at 16:19 UTC