add single files, secure server, hello world
This commit is contained in:
23
secure_server/simple_secure_server.dart
Normal file
23
secure_server/simple_secure_server.dart
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user