emptygif
ਭਾਸ਼ਾ: ਪੰਜਾਬੀ

ਸਾਰੀਆਂ ਭਾਸ਼ਾਵਾਂ ਅਤੇ ਫਰੇਮਵਰਕ

Pyramid Python

Pyramid ਲਈ Python ਸਨਿੱਪਟ, ਜੋ /pixel.gif ਦੀਆਂ ਬੇਨਤੀਆਂ ਦਾ ਜਵਾਬ ਖਾਲੀ GIF ਨਾਲ ਦਿੰਦਾ ਹੈ; GIF ਸ਼ੁਰੂਆਤ ’ਤੇ ਇੱਕ ਵਾਰ ਡੀਕੋਡ ਹੁੰਦੀ ਹੈ।

Pyramid Python

ਇੰਸਟਾਲ
pip install pyramid
ਫਾਈਲ
app.py
ਚਲਾਓ
python app.py
import base64
from wsgiref.simple_server import make_server

from pyramid.config import Configurator
from pyramid.response import Response

GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")


def pixel(request):
    return Response(body=GIF, content_type="image/gif", cache_control="no-store")


if __name__ == "__main__":
    with Configurator() as config:
        config.add_route("pixel", "/pixel.gif")
        config.add_view(pixel, route_name="pixel", request_method="GET")
        app = config.make_wsgi_app()
    make_server("0.0.0.0", 8080, app).serve_forever()

ਅਸੀਂ ਇਹ ਸਨਿੱਪਟ ਚਲਾਇਆ ਅਤੇ ਇਸ ਵੱਲੋਂ ਵਾਪਸ ਕੀਤੀਆਂ ਬਾਈਟਾਂ ਦੀ ਤੁਲਨਾ ਕੀਤੀ।

ਜਾਂਚੋ

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

ਅਧਿਕਾਰਤ ਸਾਈਟ: Pyramid

Python ਵਿੱਚ ਹੋਰ