Skip to content

Commit ad71abc

Browse files
author
pfeatherstone
committed
Added print statement indicating which URL to open in browser
1 parent 4f3bb4b commit ad71abc

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

examples/server.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ awaitable listen (
399399

400400
if (options.use_tls)
401401
{
402+
printf("Open https://localhost:%hu\n", options.port);
402403
ssl = std::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tlsv13_server);
403404
ssl->set_options(
404405
boost::asio::ssl::context::default_workarounds |
@@ -410,6 +411,8 @@ awaitable listen (
410411
ssl->use_certificate_chain_file(options.cert_file);
411412
ssl->use_private_key_file(options.key_file, boost::asio::ssl::context::pem);
412413
}
414+
else
415+
printf("Open http://localhost:%hu\n", options.port);
413416

414417
tcp_acceptor acceptor(ioc, {tcp::v4(), options.port});
415418

@@ -418,7 +421,7 @@ awaitable listen (
418421
tcp_socket sock = co_await acceptor.async_accept(make_strand(ioc));
419422

420423
if (options.use_tls)
421-
{
424+
{
422425
tls_socket tls_sock{std::move(sock), *ssl};
423426
co_spawn(sock.get_executor(), http_session(std::move(tls_sock), options, ssl), detached);
424427
}
@@ -440,26 +443,26 @@ int main(int argc, char* argv[])
440443
bool use_tls{false};
441444
CLI::App app{"HTTP and Websocket server"};
442445
try {
443-
app.add_flag("--use_tls", use_tls, "Use TLS");
446+
app.add_flag("--tls", use_tls, "Use TLS");
444447
app.parse(argc, argv);
445448
} catch (const CLI::ParseError& e) {return app.exit(e);}
446449

447450
try
448451
{
449-
std::ifstream fin0("./test/data/pride_and_prejudice.txt");
450-
std::ifstream fin1("./test/data/pride_and_prejudice.txt");
452+
std::ifstream fin0("./examples/data/pride_and_prejudice.txt");
453+
std::ifstream fin1("./examples/data/pride_and_prejudice.txt");
451454

452455
boost::asio::io_context ioc{1};
453456
boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
454457
signals.async_wait([&](auto, auto){ ioc.stop(); });
455458

456459
api_options options = {
457460
.port = 8000,
458-
.docroot = "./test/web",
461+
.docroot = "./examples/web",
459462
.username = "Tommy",
460463
.password = "Aldridge",
461-
.cert_file = "./test/data/cert.pem",
462-
.key_file = "./test/data/key.pem",
464+
.cert_file = "./examples/data/cert.pem",
465+
.key_file = "./examples/data/key.pem",
463466
.key_password = "hello there",
464467
.use_tls = use_tls,
465468

0 commit comments

Comments
 (0)