MaCH repo

This commit is contained in:
2025-07-24 12:46:01 -05:00
committed by Nick Ricketts
commit 270177fc70
48 changed files with 4873 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#include <mach.h>
#include <sqlite.h>
void mach(){
resource("home", "/",
.get = {
sqlite_query({.set_key = "greeting", .db = "hello_db", .body =
"select name "
"from greetings "
"limit 1;"
}),
mustache(.body =
"<html>"
"<body>"
"{{#greeting}}"
"<p>Hello {{name}}</p>"
"{{/greeting}}"
"</body>"
"</html>"
)
}
);
sqlite_database(
.name = "hello_db",
.connect = "file:hello.db?mode=rwc",
.migrations = {
"CREATE TABLE greetings ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT NOT NULL"
");"
},
.seeds = {
"INSERT INTO greetings(name)"
"VALUES('World');"
}
);
module(sqlite);
}