Can someone show me a sample code through which I can Post a value from a webpage to a listener server?
I am using this code for send and post operation
I am using this code for send and post operation
#include "stdafx.h"
#include <iostream>
#include <cpprest/json.h>
#include "cpprest/astreambuf.h"
#include "cpprest/http_listener.h"
using namespace web::http::experimental::listener;
using namespace web::http;
using namespace web;
int _tmain(int argc, _TCHAR* argv[])
{
uri_builder uri(L"http://localhost:2001/");
http_listener listener(uri.to_uri());
listener.support(methods::GET, [](http_request req)
{
std::cout << "Serving GET" << std::endl;
req.reply(status_codes::OK, U("<html><body><h1>It works!</h1>(Casablanca, that is a GET Request.)</body></html>"), U("text/html"));
});
listener.support(methods::PUT,[](http_request req)
{
std::cout << "Serving PUT" << std::endl;
req.reply(status_codes::OK, U("<html><body><h1>It works!</h1>(Casablanca, that is a POST Request.)</body></html>"), U("text/html"));
});
listener.support(methods::POST,[](http_request req)
{
std::cout << "Serving POST" << std::endl;
req.reply(status_codes::OK, U("<html><body><h1>It works!</h1>(Casablanca, that is a PUT Request.)</body></html>"), U("text/html"));
});
listener.open().wait();
fgetc(stdin);
listener.close().wait();
return 0;
}