Fix path security bug and added features
This commit is contained in:
@@ -2,7 +2,12 @@
|
||||
using Tesses.WebServer;
|
||||
namespace Tesses.WebServer.ConsoleApp
|
||||
{
|
||||
class JsonObj
|
||||
{
|
||||
public string Name {get;set;}="";
|
||||
|
||||
public DateTime Birthday {get;set;}=DateTime.Now;
|
||||
}
|
||||
class MainClass
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
@@ -16,6 +21,27 @@ namespace Tesses.WebServer.ConsoleApp
|
||||
await ctx.SendTextAsync("Demetria Devonne Lovato 8/20/1992");
|
||||
});
|
||||
|
||||
rserver.Add("/jsonEndpoint",async(ctx)=>{
|
||||
var res=await ctx.ReadJsonAsync<JsonObj>();
|
||||
if(res !=null)
|
||||
{
|
||||
Console.WriteLine($"Name: {res.Name}");
|
||||
Console.WriteLine($"Birthday: {res.Birthday.ToShortDateString()}");
|
||||
await ctx.SendTextAsync("The meaning of life is 42","text/plain");
|
||||
}
|
||||
});
|
||||
rserver.Add("/typewriter",(ctx)=>{
|
||||
using(var sw=ctx.GetResponseStreamWriter("text/plain"))
|
||||
{
|
||||
foreach(var c in "This is a typewriter\nwell this is cool\nThis is thanks to the chunked stream.")
|
||||
{
|
||||
sw.Write(c);
|
||||
sw.Flush();
|
||||
System.Threading.Thread.Sleep(50);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var ip=System.Net.IPAddress.Any;
|
||||
StaticServer static_server = new StaticServer(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyVideos));
|
||||
MountableServer mountable = new MountableServer(static_server);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Tesses.WebServer.NetStandard\Tesses.WebServer.NetStandard.csproj" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Tesses.WebServer.NetStandard\Tesses.WebServer.NetStandard.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user