kayleehou / myproject

Apache License 2.0
0 stars 5 forks source link

Week 11 Issue #21

Open kayleehou opened 1 year ago

kayleehou commented 1 year ago
kayleehou commented 1 year ago

I wanted the code to run regardless of if the user input had the right capitalization or not. Researched and added the .lower function My code only showed this at first: image I found the location of the problem using breakpoints: image then I ran that specific variable and got this error: built-in method lower of str object at 0x7f224fc5ebf0 After researching the problem, I realized it was a simple syntax error and I just needed parentheses after :) .lower() <-- like this

However, when I did this, the output would change everything to lowercase regardless of if the input had the right capitalizations, I wanted the output to capitalize the first letter of each word like it is in the API.

kayleehou commented 1 year ago

I used a counter in my code so if the user input title in not in the list, it would print an error message: I counted how many elements were in my list with this resource: https://stackabuse.com/python-get-number-of-elements-in-a-list/ image

kayleehou commented 1 year ago

The data in my API had problems, the first element in my list was a JPG: image I learned how to not print the first element with the pop() function which I learned from this website: https://www.geeksforgeeks.org/python-removing-first-element-of-list/#:~:text=Method%201%3A%20Remove%20Elements%20From,options%20to%20perform%20this%20task.

kayleehou commented 1 year ago

learning how to get it so that it doesn't matter if user input has punctuation or not: image

used this website for help: https://www.programiz.com/python-programming/examples/remove-punctuation

kayleehou commented 1 year ago

Starting focusing more on the connection: I was referencing code from the Jokes API for my API but I realized that the Jokes API was personally made whereas my API was already made and I needed to call it instead. This meant I was referencing the wrong code which explained why the API wouldn't show up when I generated the link. I learned the importance of understanding what it is exactly that you want your code to do.

I started referencing the Covid API instead which more closely resembled what I wanted to achieve. From the comic.pop(0) function I was using before, the incorrect data was still showing up when I tried running the link /api/MCU. With Mr. Mortensen's help, he helped me understand that the location of the function was in the wrong place. It was under my filtering response code here: image but it should've been under the entire response image

kayleehou commented 1 year ago

Another problem I had was my data was only showing up on my webiste when I typed /api/MCU once, whenever I reloaded it would show an error- internal server error.

After debugging with Mr. Mortensen, we realized I had a bug in my backend code, I was returning the Covid API data still, so the first time through the loop it would show the correct data but once it ran another time, the data was empty. It was changed to reflect to MCU_data image

kayleehou commented 1 year ago

Reminder: don't have unnecessary spaces when naming!

kayleehou commented 1 year ago

My link worked but I wasn't sure how to have the data show up on the left side of the menu: Once again, I had a typo error, I didn't change the ul id and getElementById to match like it now does below: image image This is the code for how the data now shows up in the menu: image Instead of using tr or td, we used li. We set the value of an attribute on the specific element, 'a' so that the rows would be links. We then set up the content of 'a' as a title. Title and link were both labeled based on the API. We made sure there was an li for each row, an 'a' for each li and then we added li to result.