Sending POST and PUT request from a webpage

Sep 15, 2014 at 12:10 PM
Edited Sep 15, 2014 at 1:46 PM
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
#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;
}
In POST and PUT method I want to take something from the webpage and then POST it within the string here