| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A scaffold example application built on top of MicroPhoenix.
The app can run on host BEAM (mix run) or AtomVM (./bin/atomvm-run). Both use port 8080 — do not run them at the same time.
mix deps.get
mix run --no-haltThe server will start on http://localhost:8080/
Req.get uses raw socket access through ExTCP.
If :eperm occurs, grant cap_net_raw to beam.smp:
ERL_ROOT=$(erl -noshell -eval 'io:format("~s",[code:root_dir()]), halt().')
sudo setcap cap_net_raw+ep "$ERL_ROOT"/erts-*/bin/beam.smp
getcap "$ERL_ROOT"/erts-*/bin/beam.smpExpected output includes:
.../beam.smp cap_net_raw=ep
If you see _build/... permission denied, fix ownership:
sudo chown -R "$(id -un)":"$(id -gn)" _buildBefore starting the server, you can create 5 sample Items.Item records with:
mix run -e "Enum.each(MicroScaffoldExample.Seed.names(), fn name -> MicroScaffoldExample.Items.create_item(name) end)"Requires PostgreSQL and psql. See config/config.exs for connection settings.
Build and run on AtomVM:
export ATOMVM_INSTALL_PREFIX=/path/to/AtomVM/build
export PATH="$ATOMVM_INSTALL_PREFIX/src:$PATH"
mkdir -p avm_deps # must be empty
mix deps.get
mix atomvm.packbeam
./bin/atomvm-runbin/atomvm-run loads stdlib AVMs (atomvmlib, estdlib, exavmlib) together with the app.
On AtomVM, /index2.html lists 5 seeded items (compile-time, same names as host).
Proxies http://localhost:8000/index3.html via Req.get. On AtomVM, Req uses gen_tcp (not ExTCP raw sockets). Start an upstream HTTP server on port 8000 before testing:
# example upstream (separate terminal)
python3 -m http.server 8000 --directory /path/with/index3.htmlIf upstream is down, /index3.html returns HTTP 502.
Host BEAM still uses ExTCP and needs cap_net_raw (see above).
| Method | Path | Host BEAM | AtomVM |
|---|---|---|---|
| GET | /, /index.html | Demo page | Demo page |
| GET | /api/status | Status JSON | Status JSON |
| GET | /index2.html | Items (PostgreSQL) | 5 seeded items |
| GET | /index3.html | Proxied via Req (ExTCP) | Proxied via Req (gen_tcp) |
| Back | FazBrowse Home | New Git URL |