parent
f4dc47ed7f
commit
9b3378786f
@ -1,13 +1,37 @@
|
||||
#include "crow.h"
|
||||
|
||||
#include <driver.h>
|
||||
#include <statement.h>
|
||||
|
||||
using namespace sql;
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
crow::SimpleApp app;
|
||||
Driver *driver = get_driver_instance();
|
||||
Connection *con = driver->connect(getenv("DBURL"),getenv("DBUSER"),getenv("DBPWD"));
|
||||
con->setSchema("timer_backend");
|
||||
Statement *stmt = con->createStatement();
|
||||
ResultSet *res = stmt->executeQuery("SELECT seconds FROM sessions;");
|
||||
|
||||
while (res->next()) {
|
||||
cout << "\t... MySQL replies: ";
|
||||
cout << res->getString("seconds") << endl;
|
||||
cout << "\t... MySQL says it again: ";
|
||||
cout << res->getString(1) << endl;
|
||||
}
|
||||
|
||||
delete res;
|
||||
delete stmt;
|
||||
delete con;
|
||||
|
||||
crow::SimpleApp app;
|
||||
|
||||
CROW_ROUTE(app, "/")([](){
|
||||
return "Hello world";
|
||||
});
|
||||
CROW_ROUTE(app, "/seconds")([](){
|
||||
crow::json::wvalue x({{"message", "Hello, World!"}});
|
||||
return x;
|
||||
});
|
||||
|
||||
app.port(18080).run();
|
||||
app.port(18080).run();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in new issue