Web framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

example.js 804B

12345678910111213141516171819202122
  1. // Replace with require("webframe")
  2. var webframe = require("./index.js");
  3. var mw = webframe.middleware;
  4. var app = new webframe.App();
  5. // Endpoint which uses the "params" middleware to parse URL parameters
  6. app.get("/params-example", [ mw.params ], (req, res) => {
  7. res.end("Hello, "+req.params.name);
  8. });
  9. // Endpoint which uses the "payload" middleware to get the payload as a string
  10. app.post("/payload-example", [ mw.payload ], (req, res) => {
  11. res.end(req.payload);
  12. });
  13. // When a an endpoint path starts with a ^, it's interpreted as a
  14. // regular expression pattern. "^.*" matches everything (though endpoints
  15. // with explicit paths, like the "/endpoint" above, are prioritized).
  16. //
  17. // webframe.staic("web") returns a function which serves the file in "web".
  18. app.get("^.*", webframe.static("web"));