Добавлен проект с Web API Server.
This commit is contained in:
parent
468365e10a
commit
e320118245
14
CyberSystem/ApiServer/ApiServer.csproj
Normal file
14
CyberSystem/ApiServer/ApiServer.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
26
CyberSystem/ApiServer/Controllers/PostContoller.cs
Normal file
26
CyberSystem/ApiServer/Controllers/PostContoller.cs
Normal file
@ -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!!!";
|
||||
}
|
||||
}
|
||||
}
|
23
CyberSystem/ApiServer/Program.cs
Normal file
23
CyberSystem/ApiServer/Program.cs
Normal file
@ -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();
|
31
CyberSystem/ApiServer/Properties/launchSettings.json
Normal file
31
CyberSystem/ApiServer/Properties/launchSettings.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
CyberSystem/ApiServer/appsettings.Development.json
Normal file
8
CyberSystem/ApiServer/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
CyberSystem/ApiServer/appsettings.json
Normal file
9
CyberSystem/ApiServer/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
// Создаем наш серверный сокет.
|
||||
|
Loading…
Reference in New Issue
Block a user