forked from artyom-beilis/cppcms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.cpp
More file actions
46 lines (41 loc) · 1.08 KB
/
hello.cpp
File metadata and controls
46 lines (41 loc) · 1.08 KB
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
45
46
#include <cppcms/application.h>
#include <cppcms/applications_pool.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
#include <iostream>
#include "content.h"
using namespace std;
class hello: public cppcms::application {
public:
hello(cppcms::service &s) :
cppcms::application(s)
{
}
void main(std::string /*unused*/)
{
content::message c;
if(request().request_method()=="POST") {
c.info.load(context());
if(c.info.validate()) {
c.name=c.info.name.value();
c.sex=c.info.sex.selected_id();
c.state=c.info.marital.selected_id();
c.age=c.info.age.value();
c.info.clear();
}
}
render("message",c);
}
};
int main(int argc,char ** argv)
{
try {
cppcms::service app(argc,argv);
app.applications_pool().mount(cppcms::applications_factory<hello>());
app.run();
}
catch(std::exception const &e) {
cerr<<e.what()<<endl;
}
}
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4