2024-01-18 13:36:24 -05:00
|
|
|
#include <crow.h>
|
|
|
|
#include <crow/app.h>
|
|
|
|
|
2024-01-22 15:12:28 -05:00
|
|
|
#include "isbn-interaction.h"
|
2024-01-18 13:36:24 -05:00
|
|
|
|
|
|
|
std::string print_hello()
|
|
|
|
{
|
2024-01-22 15:12:28 -05:00
|
|
|
return "server is running!";
|
2024-01-18 13:36:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
crow::SimpleApp app;
|
|
|
|
|
|
|
|
CROW_ROUTE(app, "/")([](){
|
|
|
|
return crow::response(print_hello());
|
|
|
|
});
|
|
|
|
|
|
|
|
CROW_ROUTE(app, "/books")([](){
|
|
|
|
return crow::response(get_all_books());
|
|
|
|
});
|
|
|
|
|
2024-01-24 10:54:38 -05:00
|
|
|
CROW_ROUTE(app, "/add/<string>")
|
|
|
|
([](std::string isbn)
|
|
|
|
{
|
2024-01-31 18:54:39 -05:00
|
|
|
crow::response response(add_new_book(isbn));
|
|
|
|
response.add_header("Access-Control-Allow-Origin", "*");
|
2024-01-31 18:58:46 -05:00
|
|
|
return response;
|
2024-01-24 10:54:38 -05:00
|
|
|
});
|
|
|
|
|
2024-01-24 18:44:46 -05:00
|
|
|
CROW_ROUTE(app, "/remove/<string>")
|
|
|
|
([](std::string id)
|
|
|
|
{
|
|
|
|
return crow::response(remove_book(id));
|
|
|
|
});
|
2024-01-24 10:54:38 -05:00
|
|
|
|
|
|
|
|
2024-01-18 13:36:24 -05:00
|
|
|
app.port(18080).run();
|
|
|
|
}
|