From 977efa4325f8e807d117e6afe1c728620e4e0cfc Mon Sep 17 00:00:00 2001 From: Elahn Date: Thu, 14 Jan 2021 19:03:44 -0800 Subject: [PATCH] I removed the enable cors feature. I then added the abilitiy to accept user input for words to be defined. --- src/DictionaryBackend/DefinitionResult.cs | 9 +++----- src/DictionaryBackend/Dictionary.sln | 25 +++++++++++++++++++++++ src/DictionaryBackend/Program.cs | 12 +++++------ 3 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 src/DictionaryBackend/Dictionary.sln diff --git a/src/DictionaryBackend/DefinitionResult.cs b/src/DictionaryBackend/DefinitionResult.cs index 98a1cfa..95623c0 100644 --- a/src/DictionaryBackend/DefinitionResult.cs +++ b/src/DictionaryBackend/DefinitionResult.cs @@ -1,14 +1,11 @@ using System.Collections.Generic; -using System.Web.Http.Cors; -// using Microsoft.AspNetCore.Cors; -using System.Console; +using Microsoft.AspNetCore.Cors; namespace Dictionary { - - [EnableCors(origins: "http://mywebclient.azurewebsites.net", headers: "*", methods: "*")] - public class Result { + public class Result + { public string definition { get; set; } public string partOfSpeech { get; set; } public List synonyms { get; set; } diff --git a/src/DictionaryBackend/Dictionary.sln b/src/DictionaryBackend/Dictionary.sln new file mode 100644 index 0000000..5951c71 --- /dev/null +++ b/src/DictionaryBackend/Dictionary.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.808.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dictionary", "Dictionary.csproj", "{09568224-1FB2-4FFB-9BBF-053049E9881D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09568224-1FB2-4FFB-9BBF-053049E9881D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09568224-1FB2-4FFB-9BBF-053049E9881D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09568224-1FB2-4FFB-9BBF-053049E9881D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09568224-1FB2-4FFB-9BBF-053049E9881D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {52AD6103-3091-4135-821F-FF994559A9DC} + EndGlobalSection +EndGlobal diff --git a/src/DictionaryBackend/Program.cs b/src/DictionaryBackend/Program.cs index afd714a..628ed71 100644 --- a/src/DictionaryBackend/Program.cs +++ b/src/DictionaryBackend/Program.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using System.Net.Http; using System.Text.Json; -using System.Web.Http.Cors; + namespace Dictionary { @@ -10,14 +10,14 @@ class Program { static async Task Main(string[] args) { - // EnableCorsAttribute cors = new EnableCorsAttribute("*", "*", "*"); - // config.EnableCors(cors); + var client = new HttpClient(); client.BaseAddress = new Uri("https://wordsapiv1.p.rapidapi.com"); - client.DefaultRequestHeaders.Add("X-Mashape-Key", "YourKey"); - - var wordToDefine = "Bicycle"; + client.DefaultRequestHeaders.Add("X-Mashape-Key", "1bc55635edmsh5d5800c31204366p15f03djsneb5918e71ce9"); + Console.WriteLine("Enter word to look up!"); + var wordToDefine = Console.ReadLine(); + try { var response = await client.GetAsync("/words/" + wordToDefine);