2022-11-15 16:05:47 +01:00
|
|
|
#include "crow.h"
|
2022-11-15 17:25:04 +01:00
|
|
|
|
|
|
|
extern "C" {
|
2022-11-15 17:05:14 +01:00
|
|
|
#include "ternarytrie.h"
|
2022-11-15 17:25:04 +01:00
|
|
|
}
|
2022-11-15 16:05:47 +01:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2022-11-15 17:05:14 +01:00
|
|
|
TernaryTrie *trie = ternarytrie_init();
|
|
|
|
|
2022-11-15 16:05:47 +01:00
|
|
|
crow::SimpleApp app;
|
|
|
|
|
2022-11-15 17:25:04 +01:00
|
|
|
CROW_ROUTE(app, "/<string>").methods(crow::HTTPMethod::Post)
|
|
|
|
([trie](std::string s){
|
|
|
|
ternarytrie_add(trie, s.c_str());
|
|
|
|
|
|
|
|
return "added";
|
|
|
|
});
|
|
|
|
CROW_ROUTE(app, "/<string>").methods(crow::HTTPMethod::Get)
|
|
|
|
([trie](std::string s){
|
|
|
|
if (ternarytrie_search(trie, s.c_str())) {
|
|
|
|
return "it's here";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "nope";
|
2022-11-15 16:05:47 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
app.port(18080).multithreaded().run();
|
|
|
|
}
|