emptygif
ભાષા: ગુજરાતી

બધી ભાષાઓ અને ફ્રેમવર્ક

Drogon C++

Drogon માટે C++ સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

Drogon C++

ફાઇલ
main.cpp
ચલાવો
cmake -B build && cmake --build build && ./build/pixel
#include <drogon/drogon.h>

#include <string>

using namespace drogon;

static const unsigned char GIF[] = {0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b};

int main() {
    static const std::string body(reinterpret_cast<const char *>(GIF), sizeof GIF);

    app().registerHandler(
        "/pixel.gif",
        [](const HttpRequestPtr &, std::function<void(const HttpResponsePtr &)> &&callback) {
            auto resp = HttpResponse::newHttpResponse();
            resp->setContentTypeCode(CT_IMAGE_GIF);
            resp->addHeader("Cache-Control", "no-store");
            resp->setBody(body);
            callback(resp);
        },
        {Get});

    app().addListener("0.0.0.0", 8080).run();
}

ફ્રેમવર્કના હાલના ડૉક્યુમેન્ટેશન સાથે મેળવીને ચકાસ્યું.

ચકાસો

curl -sI http://localhost:8080/pixel.gif

સત્તાવાર સાઇટ: Drogon

C++ માં વધુ