Menu

[r555]: / examples / trunk / forms / hello.cpp  Maximize  Restore  History

Download this file

45 lines (41 with data), 922 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <cppcms/application.h>
#include <iostream>
#include "data.h"
using namespace std;
using namespace cppcms;
class hello: public application {
public:
hello(worker_thread &worker) :
application(worker)
{
url.add("^/?$",
boost::bind(&hello::say_hello,this));
use_template("view");
}
void say_hello()
{
data::message c;
if(env->getRequestMethod()=="POST") {
c.info.load(*cgi);
if(c.info.validate()) {
c.name=c.info.name.get();
c.sex=c.info.sex.get();
c.state=c.info.matrial.get();
c.age=c.info.age.get();
c.info.clear();
}
}
render("message",c);
}
};
int main(int argc,char ** argv)
{
try {
manager app(argc,argv);
app.set_worker(new application_factory<hello>());
app.execute();
}
catch(std::exception const &e) {
cerr<<e.what()<<endl;
}
}
MongoDB Logo MongoDB