Crow/example.cpp

38 lines
744 B
C++
Raw Normal View History

2014-03-30 13:53:56 +00:00
#include "flask.h"
#include <sstream>
2014-03-30 13:53:56 +00:00
int main()
{
flask::Flask app;
2014-04-14 15:31:51 +00:00
FLASK_ROUTE(app, "/")
.name("hello")
([]{
return "Hello World!";
});
2014-04-15 20:20:52 +00:00
FLASK_ROUTE(app, "/about")
([](){
2014-04-01 13:58:52 +00:00
return "About Flask example.";
});
FLASK_ROUTE(app,"/hello/<int>")
([](int count){
if (count > 100)
return flask::response(400);
std::ostringstream os;
os << count << " bottles of beer!";
return flask::response(os.str());
});
// Compile error with message "Handler type is mismatched with URL paramters"
//FLASK_ROUTE(app,"/another/<int>")
//([](int a, int b){
//return flask::response(500);
//});
app.port(8080)
.run();
2014-03-30 13:53:56 +00:00
}