2021-04-05 08:21:14 +00:00
|
|
|
#include <crow.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
crow::SimpleApp app;
|
|
|
|
|
2021-11-25 11:45:38 +00:00
|
|
|
CROW_ROUTE(app, "/")
|
2021-11-27 12:28:50 +00:00
|
|
|
([]() { return "Hello"; });
|
2021-04-12 05:25:09 +00:00
|
|
|
|
|
|
|
//Setting a custom route for any URL that isn't defined, instead of a simple 404.
|
|
|
|
CROW_CATCHALL_ROUTE(app)
|
2021-11-27 12:28:50 +00:00
|
|
|
([](crow::response& res) {
|
2021-08-21 01:49:17 +00:00
|
|
|
if (res.code == 404)
|
|
|
|
{
|
|
|
|
res.body = "The URL does not seem to be correct.";
|
|
|
|
}
|
|
|
|
else if (res.code == 405)
|
|
|
|
{
|
|
|
|
res.body = "The HTTP method does not seem to be correct.";
|
|
|
|
}
|
2021-11-25 11:45:38 +00:00
|
|
|
res.end(); });
|
2021-04-05 08:21:14 +00:00
|
|
|
|
2021-04-12 05:25:09 +00:00
|
|
|
app.port(18080).run();
|
2021-04-05 08:21:14 +00:00
|
|
|
}
|