···11+# app
22+33+[](https://hex.pm/packages/app)
44+[](https://hexdocs.pm/app/)
55+66+A Gleam project
77+88+## Quick start
99+1010+```sh
1111+gleam run # Run the project
1212+gleam test # Run the tests
1313+gleam shell # Run an Erlang shell
1414+```
1515+1616+## Installation
1717+1818+If available on Hex this package can be added to your Gleam project:
1919+2020+```sh
2121+gleam add app
2222+```
2323+2424+and its documentation can be found at <https://hexdocs.pm/app>.
···11+# This file was generated by Gleam
22+# You typically do not need to edit this file
33+44+packages = [
55+ { name = "gleam_erlang", version = "0.20.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "F216A80C8FDFF774447B494D5E08AE4E9A911E971727B9A78FEBF5F300914584" },
66+ { name = "gleam_http", version = "3.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "FAE9AE3EB1CA90C2194615D20FFFD1E28B630E84DACA670B28D959B37BCBB02C" },
77+ { name = "gleam_otp", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_erlang"], otp_app = "gleam_otp", source = "hex", outer_checksum = "E31B158857E3D2AF946FE6E90E0CB21699AF226F4630E93FBEAC5DB4515F8920" },
88+ { name = "gleam_stdlib", version = "0.30.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "03710B3DA047A3683117591707FCA19D32B980229DD8CE8B0603EB5B5144F6C3" },
99+ { name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
1010+ { name = "glisten", version = "0.8.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_otp", "gleam_erlang"], otp_app = "glisten", source = "hex", outer_checksum = "6DDE276F8A2E3C79E5A580DEA05C7D87FCDE3A37FF69F607770D92686E193531" },
1111+ { name = "mist", version = "0.13.1", build_tools = ["gleam"], requirements = ["gleam_http", "glisten", "gleam_stdlib", "gleam_erlang"], otp_app = "mist", source = "hex", outer_checksum = "178EDF5F396570DD53BE2A94C8F9759072093DACB81B62CD47A620B961DB2F2D" },
1212+ { name = "simplifile", version = "0.1.8", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "9CED66E65AF32C98AA336A65365A498DCF018D2A3D96A05D861C4005DCDE4D2D" },
1313+ { name = "wisp", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib", "mist", "simplifile"], source = "local", path = "/Users/louis/src/gleam/wisp" },
1414+]
1515+1616+[requirements]
1717+gleam_stdlib = { version = "~> 0.30" }
1818+gleeunit = { version = "~> 0.10" }
1919+wisp = { path = "../.." }
+35
examples/0-hello-world/src/app.gleam
···11+import gleam/string_builder
22+import gleam/erlang/process
33+import mist
44+import wisp
55+66+/// The HTTP request handler- your application!
77+pub fn handle_request(req: wisp.Request) -> wisp.Response {
88+ use _req <- middleware(req)
99+ let body = string_builder.from_string("<h1>Hello, Joe!</h1>")
1010+ wisp.html_response(body, 200)
1111+}
1212+1313+/// The middleware stack that the request handler uses.
1414+pub fn middleware(
1515+ req: wisp.Request,
1616+ service: fn(wisp.Request) -> wisp.Response,
1717+) -> wisp.Response {
1818+ let req = wisp.method_override(req)
1919+ use <- wisp.log_requests(req)
2020+ use <- wisp.rescue_crashes
2121+2222+ service(req)
2323+}
2424+2525+/// Lastly, the main function that runs the service using the Mist HTTP server.
2626+pub fn main() {
2727+ let assert Ok(_) =
2828+ wisp.mist_service(handle_request)
2929+ |> mist.new
3030+ |> mist.port(8000)
3131+ |> mist.start_http
3232+3333+ // Mist runs in new Erlang process, so put this one to sleep.
3434+ process.sleep_forever()
3535+}
+12
examples/0-hello-world/test/app_test.gleam
···11+import gleeunit
22+import gleeunit/should
33+44+pub fn main() {
55+ gleeunit.main()
66+}
77+88+// gleeunit test functions end in `_test`
99+pub fn hello_world_test() {
1010+ 1
1111+ |> should.equal(1)
1212+}