Dart Frog Dart
Snippet na Dart don Dart Frog da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.
Dart Frog Dart
// 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'},
);
}
Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.
Duba shi
curl -sI http://localhost:8080/pixel.gif