add single files, secure server, hello world

This commit is contained in:
2020-02-09 23:35:18 +08:00
parent 9f8a7ccc59
commit 2ddf9538ea
17 changed files with 270 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import 'dart:io';
String certificateChain = 'server_chain.pem';
String serverKey = 'server_key.pem';
Future main() async {
var serverContext = SecurityContext();
serverContext.useCertificateChain(certificateChain);
serverContext.usePrivateKey(serverKey, password: 'dartdart');
var server = await HttpServer.bindSecure(
'0.0.0.0',
8443,
serverContext,
);
print('Listening on localhost:${server.port}');
await for (HttpRequest request in server) {
print('Got request for ${request.uri.path}');
request.response
..write('Hello, world!')
..close();
}
}