gemini_server 1.0.2 gemini_server: ^1.0.2 copied to clipboard
A low-level Gemini server.
example/gemini_server_example.dart
import 'dart:convert';
import 'dart:io';
import 'package:gemini_server/gemini_server.dart';
Future<Response> handler(Request request) async {
return Response(
statusCode: StatusCode.success,
meta: "text/gemini",
body: utf8.encode("# Hello World!"),
);
}
void main() async {
// WARNING: this is a self-signed certificate
// created for example, please DO NOT use it in production!
final context = SecurityContext()
..useCertificateChain("cert/cert.pem")
..usePrivateKey("cert/key.pem", password: "example");
await GeminiServer.bind(
address: InternetAddress.anyIPv4,
port: 1965,
context: context,
callback: handler,
);
}