emptygif
Language: English

All languages and frameworks

Dart Frog Dart

A Dart snippet for Dart Frog that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Dart Frog Dart

Install
dart pub global activate dart_frog_cli
File
pixel.gif.dart
Run
dart_frog dev
// routes/pixel.gif.dart: the file name is the route.
import 'dart:convert';

import 'package:dart_frog/dart_frog.dart';

final _gif = base64Decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

Response onRequest(RequestContext context) {
  return Response.bytes(
    body: _gif,
    headers: {'content-type': 'image/gif', 'cache-control': 'no-store'},
  );
}

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Dart Frog

More in Dart