Microdot (CPython and MicroPython) Python
Đoạn mã Python cho Microdot (CPython and MicroPython), trả lời các yêu cầu tới /pixel.gif bằng GIF rỗng, được giải mã một lần khi khởi động.
Microdot (CPython and MicroPython) Python
import binascii # available on MicroPython as well as CPython
from microdot import Microdot
GIF = binascii.a2b_base64("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
app = Microdot()
@app.get("/pixel.gif")
async def pixel(request):
return GIF, 200, {"Content-Type": "image/gif", "Cache-Control": "no-store"}
app.run(port=8080)
Chúng tôi đã chạy đoạn mã này và so sánh các byte nó trả về.
Kiểm tra
curl -sI http://localhost:8080/pixel.gif
Trang chính thức: Microdot (CPython and MicroPython)