diff --git a/AspNetCoreApi/AspNetCoreApi.csproj b/AspNetCoreApi/AspNetCoreApi.csproj new file mode 100644 index 0000000..9daa180 --- /dev/null +++ b/AspNetCoreApi/AspNetCoreApi.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/AspNetCoreApi/AspNetCoreApi.http b/AspNetCoreApi/AspNetCoreApi.http new file mode 100644 index 0000000..fe1ef22 --- /dev/null +++ b/AspNetCoreApi/AspNetCoreApi.http @@ -0,0 +1,6 @@ +@AspNetCoreApi_HostAddress = http://localhost:5184 + +GET {{AspNetCoreApi_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/AspNetCoreApi/AspNetCoreApi.sln b/AspNetCoreApi/AspNetCoreApi.sln new file mode 100644 index 0000000..d814b32 --- /dev/null +++ b/AspNetCoreApi/AspNetCoreApi.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34916.146 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreApi", "AspNetCoreApi.csproj", "{9F034B6E-BE32-4595-938B-E20887FFC9F0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "솔루션 항목", "솔루션 항목", "{B96F1AEC-9A65-4C5C-BB1C-C5F4EDB2BB80}" + ProjectSection(SolutionItems) = preProject + ..\README.md = ..\README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9F034B6E-BE32-4595-938B-E20887FFC9F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F034B6E-BE32-4595-938B-E20887FFC9F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F034B6E-BE32-4595-938B-E20887FFC9F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F034B6E-BE32-4595-938B-E20887FFC9F0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {001DB78D-4DC6-4FC7-A755-EC9E24B64862} + EndGlobalSection +EndGlobal diff --git a/AspNetCoreApi/Controllers/WeatherForecastController.cs b/AspNetCoreApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..4b997e3 --- /dev/null +++ b/AspNetCoreApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace AspNetCoreApi.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/AspNetCoreApi/Program.cs b/AspNetCoreApi/Program.cs new file mode 100644 index 0000000..562f02a --- /dev/null +++ b/AspNetCoreApi/Program.cs @@ -0,0 +1,36 @@ + +namespace AspNetCoreApi +{ + public class Program + { + public static void Main(string[] args) + { + 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.UseHttpsRedirection(); + + app.UseAuthorization(); + + + app.MapControllers(); + + app.Run(); + } + } +} diff --git a/AspNetCoreApi/Properties/launchSettings.json b/AspNetCoreApi/Properties/launchSettings.json new file mode 100644 index 0000000..166a0ab --- /dev/null +++ b/AspNetCoreApi/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:2353", + "sslPort": 44332 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5184", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7135;http://localhost:5184", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/AspNetCoreApi/WeatherForecast.cs b/AspNetCoreApi/WeatherForecast.cs new file mode 100644 index 0000000..c030e39 --- /dev/null +++ b/AspNetCoreApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace AspNetCoreApi +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/AspNetCoreApi/appsettings.Development.json b/AspNetCoreApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/AspNetCoreApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/AspNetCoreApi/appsettings.json b/AspNetCoreApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/AspNetCoreApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/README.md b/README.md index a0e01c6..b804bbc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # ASPNetCoreBlazorLearningWBS +### Learning ASP.NET Core and Blazor + + +- API Server \ No newline at end of file