diff --git a/CyberSystem/ApiServer/ApiServer.csproj b/CyberSystem/ApiServer/ApiServer.csproj new file mode 100644 index 0000000..8768216 --- /dev/null +++ b/CyberSystem/ApiServer/ApiServer.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/CyberSystem/ApiServer/Controllers/PostContoller.cs b/CyberSystem/ApiServer/Controllers/PostContoller.cs new file mode 100644 index 0000000..25b31a3 --- /dev/null +++ b/CyberSystem/ApiServer/Controllers/PostContoller.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Mvc; +using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute; + + +namespace ApiServer.Controllers +{ + [ApiController] + [Route("api")] + public class PostContoller + { + [HttpGet] + [Route("post")] + public string GetUserPost() + { + return "Hello, user! Your post is best!"; + } + + [HttpGet] + [Route("adminpost")] + public string GetAdmin() + { + return "Hello, Admin! It's your POST!!!"; + } + } +} diff --git a/CyberSystem/ApiServer/Program.cs b/CyberSystem/ApiServer/Program.cs new file mode 100644 index 0000000..0b40fc1 --- /dev/null +++ b/CyberSystem/ApiServer/Program.cs @@ -0,0 +1,23 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +//builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + //app.UseSwagger(); + //app.UseSwaggerUI(); +} + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/CyberSystem/ApiServer/Properties/launchSettings.json b/CyberSystem/ApiServer/Properties/launchSettings.json new file mode 100644 index 0000000..e1ba3c5 --- /dev/null +++ b/CyberSystem/ApiServer/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3819", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:12345", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/CyberSystem/ApiServer/appsettings.Development.json b/CyberSystem/ApiServer/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/CyberSystem/ApiServer/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/CyberSystem/ApiServer/appsettings.json b/CyberSystem/ApiServer/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/CyberSystem/ApiServer/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/CyberSystem/CyberSystem.sln b/CyberSystem/CyberSystem.sln index 6d19b17..fce98b7 100644 --- a/CyberSystem/CyberSystem.sln +++ b/CyberSystem/CyberSystem.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BerklySocketServer", "CyberSystem\BerklySocketServer.csproj", "{732F06D2-F9CE-40A3-8281-48D7A41E0F79}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiServer", "ApiServer\ApiServer.csproj", "{7C72B3F0-8B39-4D48-8D9B-9A56046E5DA8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {732F06D2-F9CE-40A3-8281-48D7A41E0F79}.Debug|Any CPU.Build.0 = Debug|Any CPU {732F06D2-F9CE-40A3-8281-48D7A41E0F79}.Release|Any CPU.ActiveCfg = Release|Any CPU {732F06D2-F9CE-40A3-8281-48D7A41E0F79}.Release|Any CPU.Build.0 = Release|Any CPU + {7C72B3F0-8B39-4D48-8D9B-9A56046E5DA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C72B3F0-8B39-4D48-8D9B-9A56046E5DA8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C72B3F0-8B39-4D48-8D9B-9A56046E5DA8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C72B3F0-8B39-4D48-8D9B-9A56046E5DA8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CyberSystem/CyberSystem/Server.cs b/CyberSystem/CyberSystem/Server.cs index 72d0b00..c6cb049 100644 --- a/CyberSystem/CyberSystem/Server.cs +++ b/CyberSystem/CyberSystem/Server.cs @@ -8,7 +8,7 @@ public class Server public static void Main() { // Настройка IP-адреса сервера и номера порта. - var serverAddress = IPAddress.Parse("127.0.0.7"); + var serverAddress = IPAddress.Parse("0.0.0.0"); var serverPort = 8000; // Создаем наш серверный сокет.