SimpleApi.vala 469 B

123456789101112131415161718
  1. using Astralis;
  2. void main() {
  3. var server = new Server(8080);
  4. server.map_get("/hello", (context) => {
  5. print("Handling /hello\n");
  6. context.response.body = "Hello from Astralis!";
  7. context.response.content_type = "text/plain";
  8. });
  9. server.map_get("/json", (context) => {
  10. context.response.body = "{ \"message\": \"Hello JSON\" }";
  11. context.response.content_type = "application/json";
  12. });
  13. server.run();
  14. }