அனைத்து மொழிகளும் ஃப்ரேம்வொர்க்குகளும்
Nim standard library (asynchttpserver) Nim
/pixel.gif க்கு வரும் ரெக்வெஸ்ட்களுக்கு empty GIF மூலம் பதிலளிக்கும், Nim standard library (asynchttpserver) க்கான Nim ஸ்னிப்பெட். GIF ஸ்டார்ட்அப்பில் ஒருமுறை மட்டுமே டீகோட் செய்யப்படுகிறது.
Nim standard library (asynchttpserver) Nim
import std/[asyncdispatch, asynchttpserver, base64]
# Decoded at compile time; a const is also safe to use from the gcsafe callback.
const gif = decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
proc handler(req: Request) {.async.} =
if req.reqMethod == HttpGet and req.url.path == "/pixel.gif":
let headers = newHttpHeaders({"Content-Type": "image/gif", "Cache-Control": "no-store"})
await req.respond(Http200, gif, headers)
else:
await req.respond(Http404, "Not Found")
let server = newAsyncHttpServer()
waitFor server.serve(Port(8080), handler)
ஃப்ரேம்வொர்க்கின் தற்போதைய டாக்குமென்டேஷனுடன் ஒப்பிட்டுச் சரிபார்க்கப்பட்டது.
சரிபார்
curl -sI http://localhost:8080/pixel.gif