MaCH repo
This commit is contained in:
4
03_hello_world_html_db/create_hello_world_table.sql
Normal file
4
03_hello_world_html_db/create_hello_world_table.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
CREATE TABLE greetings (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
3
03_hello_world_html_db/get_hello_world.sql
Normal file
3
03_hello_world_html_db/get_hello_world.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select name
|
||||
from greetings
|
||||
limit 1;
|
||||
7
03_hello_world_html_db/hello_world.mustache.html
Normal file
7
03_hello_world_html_db/hello_world.mustache.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
{{#hello_world_data}}
|
||||
<p>Hello {{name}}</p>
|
||||
{{/hello_world_data}}
|
||||
</body>
|
||||
</html>
|
||||
18
03_hello_world_html_db/main.c
Normal file
18
03_hello_world_html_db/main.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <mach.h>
|
||||
#include <sqlite.h>
|
||||
|
||||
void mach(){
|
||||
sqlite_database(
|
||||
.name = "hello_db",
|
||||
.connect = "file:hello.db?mode=rwc",
|
||||
.migrations = {"create_hello_world_table"},
|
||||
.seeds = {"seed_hello_world"}
|
||||
);
|
||||
|
||||
resource("home", "/",
|
||||
.get = {
|
||||
sqlite_query({"hello_db", "get_hello_world", "hello_world_data"}),
|
||||
mustache("hello_world")
|
||||
}
|
||||
);
|
||||
}
|
||||
2
03_hello_world_html_db/seed_hello_world.sql
Normal file
2
03_hello_world_html_db/seed_hello_world.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
INSERT INTO greetings(name)
|
||||
VALUES('World');
|
||||
Reference in New Issue
Block a user