diff options
Diffstat (limited to 'sandbox/test-projekat-danijel/backend')
9 files changed, 215 insertions, 0 deletions
diff --git a/sandbox/test-projekat-danijel/backend/backend.sln b/sandbox/test-projekat-danijel/backend/backend.sln new file mode 100644 index 00000000..e596b58d --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31729.503 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "backend", "backend\backend.csproj", "{8D063D72-AE73-46EE-BF45-096635FC3653}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8D063D72-AE73-46EE-BF45-096635FC3653}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D063D72-AE73-46EE-BF45-096635FC3653}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D063D72-AE73-46EE-BF45-096635FC3653}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D063D72-AE73-46EE-BF45-096635FC3653}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B788BDB1-7DDF-4422-9894-148A6C6315F9} + EndGlobalSection +EndGlobal diff --git a/sandbox/test-projekat-danijel/backend/backend/Controllers/ValuesController.cs b/sandbox/test-projekat-danijel/backend/backend/Controllers/ValuesController.cs new file mode 100644 index 00000000..c2076429 --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/Controllers/ValuesController.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Cors; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace backend.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + // GET: api/<ValuesController> + [HttpGet] + public IEnumerable<string> Get() + { + return colors.ToArray(); + } + + private static List<string> colors = new List<string>(new string[] { "#ff0000", "#00ff00", "#0000ff" }); + + // POST api/<ValuesController> + [HttpPost] + public string Post([FromBody] RGB color) + { + string hex = string.Format("#{0:X2}{1:X2}{2:X2}", color.red, color.green, color.blue); + colors.Add(hex); + return hex; + } + } + + public class RGB + { + public int red { get; set; } + public int green { get; set; } + public int blue { get; set; } + } +} + + diff --git a/sandbox/test-projekat-danijel/backend/backend/Program.cs b/sandbox/test-projekat-danijel/backend/backend/Program.cs new file mode 100644 index 00000000..7456d853 --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/Program.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace backend +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup<Startup>(); + }); + } +} diff --git a/sandbox/test-projekat-danijel/backend/backend/Properties/launchSettings.json b/sandbox/test-projekat-danijel/backend/backend/Properties/launchSettings.json new file mode 100644 index 00000000..4b13e8f4 --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:57127", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "backend": { + "commandName": "Project", + "launchBrowser": false, + "launchUrl": "api/values", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/sandbox/test-projekat-danijel/backend/backend/Startup.cs b/sandbox/test-projekat-danijel/backend/backend/Startup.cs new file mode 100644 index 00000000..12d95d19 --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/Startup.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors.Infrastructure; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace backend +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + services.AddCors(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseCors(options => options.WithOrigins("http://localhost:4200").AllowAnyMethod().AllowAnyHeader()); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/sandbox/test-projekat-danijel/backend/backend/appsettings.Development.json b/sandbox/test-projekat-danijel/backend/backend/appsettings.Development.json new file mode 100644 index 00000000..8983e0fc --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/sandbox/test-projekat-danijel/backend/backend/appsettings.json b/sandbox/test-projekat-danijel/backend/backend/appsettings.json new file mode 100644 index 00000000..d9d9a9bf --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/sandbox/test-projekat-danijel/backend/backend/backend.csproj b/sandbox/test-projekat-danijel/backend/backend/backend.csproj new file mode 100644 index 00000000..fe90636c --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/backend.csproj @@ -0,0 +1,9 @@ +<Project Sdk="Microsoft.NET.Sdk.Web"> + + <PropertyGroup> + <TargetFramework>net5.0</TargetFramework> + <StartupObject>backend.Program</StartupObject> + </PropertyGroup> + + +</Project> diff --git a/sandbox/test-projekat-danijel/backend/backend/backend.csproj.user b/sandbox/test-projekat-danijel/backend/backend/backend.csproj.user new file mode 100644 index 00000000..ae173cce --- /dev/null +++ b/sandbox/test-projekat-danijel/backend/backend/backend.csproj.user @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> + <DebuggerFlavor>ProjectDebugger</DebuggerFlavor> + </PropertyGroup> + <PropertyGroup> + <ActiveDebugProfile>backend</ActiveDebugProfile> + <Controller_SelectedScaffolderID>ApiControllerWithActionsScaffolder</Controller_SelectedScaffolderID> + <Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath> + </PropertyGroup> +</Project>
\ No newline at end of file |