data() - nomadnt-iot/uHTTP GitHub Wiki

data()

Description

Retrieve a given value from a (POST, PUT, DELETE, ...) data using key char

Syntax

server.data(key);

Parameters

key: the key of the value that you want to retrieve from (POST, PUT, DELETE, ...) data

Returns

const char array containing the key value

Example

#include <SPI.h>
#include <Ethernet.h>
#include <uHTTP.h>

byte macaddr[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
byte ip4addr[4] = {192, 168, 0, 254};

uHTTP server = uHTTP(80);

void setup(){
    Ethernet.begin(macaddr, ip4addr);

    Serial.print(F("Starting uHTTP at "));
    Serial.print(Ethernet.localIP());
    Serial.println(":80");

    server.begin();
}

void loop(){
    EthernetClient response = server.available();
    if(response){
        Serial.println(server.data("foo"));

        response.println("HTTP/1.1 200 OK");
        response.println("Content-Type: text/plain");
        response.println();
        response.println("Hello World!");
        response.stop();
    }
}
⚠️ **GitHub.com Fallback** ⚠️