From 43e3ad4c003e3daef9aab04c3300f11006df0b0a Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Sat, 16 May 2020 13:01:12 +0200 Subject: [PATCH] Add support for static files. --- Source/MQTTnet.Server/MQTTnet.Server.csproj | 11 ++--- Source/MQTTnet.Server/Program.cs | 3 +- Source/MQTTnet.Server/Web/wwwroot/Hello.txt | 1 + .../Web/wwwroot/pahoJS_Test.html | 41 +++++++++++++++++++ 4 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 Source/MQTTnet.Server/Web/wwwroot/Hello.txt create mode 100644 Source/MQTTnet.Server/Web/wwwroot/pahoJS_Test.html diff --git a/Source/MQTTnet.Server/MQTTnet.Server.csproj b/Source/MQTTnet.Server/MQTTnet.Server.csproj index 0b081af8..a95c5bfd 100644 --- a/Source/MQTTnet.Server/MQTTnet.Server.csproj +++ b/Source/MQTTnet.Server/MQTTnet.Server.csproj @@ -29,13 +29,6 @@ 1701;1702 - - - - - - - Always @@ -72,11 +65,13 @@ Always + + Always + - diff --git a/Source/MQTTnet.Server/Program.cs b/Source/MQTTnet.Server/Program.cs index 571df2bf..093c6072 100644 --- a/Source/MQTTnet.Server/Program.cs +++ b/Source/MQTTnet.Server/Program.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Hosting; using MQTTnet.Server.Web; using System; using System.Diagnostics; +using System.IO; using System.Reflection; namespace MQTTnet.Server @@ -21,8 +22,8 @@ namespace MQTTnet.Server webBuilder.ConfigureKestrel(serverOptions => { }) + .UseWebRoot(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot")) .UseStartup(); - }).Build().Run(); return 0; diff --git a/Source/MQTTnet.Server/Web/wwwroot/Hello.txt b/Source/MQTTnet.Server/Web/wwwroot/Hello.txt new file mode 100644 index 00000000..782edd32 --- /dev/null +++ b/Source/MQTTnet.Server/Web/wwwroot/Hello.txt @@ -0,0 +1 @@ +World \ No newline at end of file diff --git a/Source/MQTTnet.Server/Web/wwwroot/pahoJS_Test.html b/Source/MQTTnet.Server/Web/wwwroot/pahoJS_Test.html new file mode 100644 index 00000000..9f445797 --- /dev/null +++ b/Source/MQTTnet.Server/Web/wwwroot/pahoJS_Test.html @@ -0,0 +1,41 @@ + + + + paho JS Example + + + + + + + + + + + + \ No newline at end of file