அனைத்து மொழிகளும் ஃப்ரேம்வொர்க்குகளும்
Raw ASGI (Uvicorn, Granian, Hypercorn) Python
/pixel.gif க்கு வரும் ரெக்வெஸ்ட்களுக்கு empty GIF மூலம் பதிலளிக்கும், Raw ASGI (Uvicorn, Granian, Hypercorn) க்கான Python ஸ்னிப்பெட். GIF ஸ்டார்ட்அப்பில் ஒருமுறை மட்டுமே டீகோட் செய்யப்படுகிறது.
Raw ASGI (Uvicorn, Granian, Hypercorn) Python
import base64
GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
HEADERS = [
(b"content-type", b"image/gif"),
(b"content-length", str(len(GIF)).encode()),
(b"cache-control", b"no-store"),
]
async def app(scope, receive, send):
if scope["type"] != "http":
return
if scope["method"] == "GET" and scope["path"] == "/pixel.gif":
await send({"type": "http.response.start", "status": 200, "headers": HEADERS})
await send({"type": "http.response.body", "body": GIF})
else:
await send({"type": "http.response.start", "status": 404, "headers": []})
await send({"type": "http.response.body", "body": b""})
இந்த ஸ்னிப்பெட்டை ரன் செய்து, அது திருப்பித் தந்த பைட்களை ஒப்பிட்டுப் பார்த்தோம்.
சரிபார்
curl -sI http://localhost:8080/pixel.gif
அதிகாரப்பூர்வ சைட்: Raw ASGI (Uvicorn, Granian, Hypercorn)