-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (29 loc) · 1.01 KB
/
Copy pathmain.cpp
File metadata and controls
43 lines (29 loc) · 1.01 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
#include <nodepp/nodepp.h>
#include <express/http.h>
using namespace nodepp;
void onMain() {
auto app = express::http::add();
app.POST( "/file", []( express_http_t cli ){
cli.parse_stream().then([=]( object_t obj ){
console::log( ">>", json::stringify( obj ) );
cli.header( "Content-Type", "text/html" );
cli.send (" done ");
}).fail([=]( except_t err ){
console::log( ">>", err );
});
} );
app.GET( []( express_http_t cli ){
console::log( ">>", cli.get_fd() );
cli.header( "Content-Type", "text/html" );
cli.send ( NODEPP_STRINGIFY (
<form action="/file" enctype="multipart/form-data" method="POST">
<h1> Send File </h1>
<input type="file" name="file" />
<input type="submit" />
</form>
) );
} );
app.listen( "localhost", 8000, []( socket_t ){
console::log( "server started at http://localhost:8000" );
});
}