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

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

vibe.d D

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

vibe.d D

ફાઇલ
server.d
ચલાવો
dub run --single server.d
/+ dub.sdl:
    name "pixel"
    dependency "vibe-d" version="~>0.10"
+/
import vibe.vibe;

immutable ubyte[] 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];

void pixel(HTTPServerRequest req, HTTPServerResponse res) @safe
{
    res.headers["Cache-Control"] = "no-store";
    res.writeBody(gif, "image/gif");
}

void main()
{
    auto router = new URLRouter;
    router.get("/pixel.gif", &pixel);

    auto settings = new HTTPServerSettings;
    settings.port = 8080;
    auto listener = listenHTTP(settings, router);
    scope (exit) listener.stopListening();

    runApplication();
}

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

ચકાસો

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

સત્તાવાર સાઇટ: vibe.d