aboutsummaryrefslogtreecommitdiffstats
path: root/example.cpp
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-04-27 02:19:59 +0900
committeripknHama <ipknhama@gmail.com>2014-04-27 03:16:00 +0900
commitf8893eb138eae88f35ba752221a02b318d275364 (patch)
tree9ffcd76c289bc8a9f7b21a4dd16c1ba434ed891e /example.cpp
parent8eceb3f7ccc3dc57263c7ed2529493d831d59f61 (diff)
downloadcrow-f8893eb138eae88f35ba752221a02b318d275364.tar.gz
crow-f8893eb138eae88f35ba752221a02b318d275364.zip
rename flask to crow
Diffstat (limited to 'example.cpp')
-rw-r--r--example.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/example.cpp b/example.cpp
index 19cb158..92bc19c 100644
--- a/example.cpp
+++ b/example.cpp
@@ -1,56 +1,56 @@
-#include "flask.h"
+#include "crow.h"
#include "json.h"
#include <sstream>
int main()
{
- flask::Flask app;
+ crow::Crow app;
- FLASK_ROUTE(app, "/")
+ CROW_ROUTE(app, "/")
.name("hello")
([]{
return "Hello World!";
});
- FLASK_ROUTE(app, "/about")
+ CROW_ROUTE(app, "/about")
([](){
- return "About Flask example.";
+ return "About Crow example.";
});
// simple json response
- FLASK_ROUTE(app, "/json")
+ CROW_ROUTE(app, "/json")
([]{
- flask::json::wvalue x;
+ crow::json::wvalue x;
x["message"] = "Hello, World!";
return x;
});
- FLASK_ROUTE(app,"/hello/<int>")
+ CROW_ROUTE(app,"/hello/<int>")
([](int count){
if (count > 100)
- return flask::response(400);
+ return crow::response(400);
std::ostringstream os;
os << count << " bottles of beer!";
- return flask::response(os.str());
+ return crow::response(os.str());
});
// Compile error with message "Handler type is mismatched with URL paramters"
- //FLASK_ROUTE(app,"/another/<int>")
+ //CROW_ROUTE(app,"/another/<int>")
//([](int a, int b){
- //return flask::response(500);
+ //return crow::response(500);
//});
// more json example
- FLASK_ROUTE(app, "/add_json")
- ([](const flask::request& req){
- auto x = flask::json::load(req.body);
+ CROW_ROUTE(app, "/add_json")
+ ([](const crow::request& req){
+ auto x = crow::json::load(req.body);
if (!x)
- return flask::response(400);
+ return crow::response(400);
int sum = x["a"].i()+x["b"].i();
std::ostringstream os;
os << sum;
- return flask::response{os.str()};
+ return crow::response{os.str()};
});
app.port(18080)