-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock.cpp
34 lines (28 loc) · 912 Bytes
/
clock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <crow_all.h>
using namespace std;
int main() {
crow:: SimpleApp app;
CROW_ROUTE(app, "/")([](){
auto page = crow::mustache::load_text("index.html");
return page;
});
CROW_ROUTE(app, "/style.css")([](){
ifstream in("templates/style.css", ios::in | ios::binary);
if (in) {
string contents((istreambuf_iterator<char>(in)), istreambuf_iterator<char>());
return crow::response(contents);
} else {
return crow::response(404);
}
});
CROW_ROUTE(app, "/script.js")([](){
ifstream in("templates/script.js", ios::in | ios::binary);
if (in) {
string contents((istreambuf_iterator<char>(in)), istreambuf_iterator<char>());
return crow::response(contents);
} else {
return crow::response(404);
}
});
app.port(18080).multithreaded().run();
}