2014-03-30 13:53:56 +00:00
|
|
|
#include "flask.h"
|
|
|
|
|
2014-04-13 02:24:06 +00:00
|
|
|
#include <sstream>
|
2014-03-31 16:51:50 +00:00
|
|
|
|
2014-03-30 13:53:56 +00:00
|
|
|
int main()
|
|
|
|
{
|
2014-04-09 23:17:08 +00:00
|
|
|
flask::Flask app;
|
|
|
|
|
2014-04-14 15:31:51 +00:00
|
|
|
FLASK_ROUTE(app, "/")
|
2014-04-09 23:17:08 +00:00
|
|
|
.name("hello")
|
|
|
|
([]{
|
2014-03-31 16:51:50 +00:00
|
|
|
return "Hello World!";
|
|
|
|
});
|
|
|
|
|
2014-04-15 20:20:52 +00:00
|
|
|
FLASK_ROUTE(app, "/about")
|
2014-04-13 02:24:06 +00:00
|
|
|
([](){
|
2014-04-01 13:58:52 +00:00
|
|
|
return "About Flask example.";
|
|
|
|
});
|
|
|
|
|
2014-04-13 02:24:06 +00:00
|
|
|
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);
|
2014-04-09 23:17:08 +00:00
|
|
|
//});
|
|
|
|
|
2014-03-31 16:51:50 +00:00
|
|
|
app.port(8080)
|
|
|
|
.run();
|
2014-03-30 13:53:56 +00:00
|
|
|
}
|