Popular Posts Glitch App
Update 4/23/2021: The write.as team has introduced some rate-limiting features on their API to combat spam bots. That stopped this Glitch app and my other Blazor WASM apps from working.
I created a Glitch App that displays the most viewed posts on my online journal. I embedded it on my About page. Just to show how easy it is to embed a Glitch app into a Write.as post, I embedded it at the bottom of this post too. For more information on embedding Glitch apps into posts on Write.as, look here.
Some notes on what I learned while working on this app:
- Similar to when I worked on the Search app, you'll want to have a basic understanding of web development, which means knowing a little bit about HTML, CSS, some Javascript and some Python. For this app though, I had to do a lot more Python programming.
- To create this app, I remixed the Search app I created. I did this because the app already had code to search through all the posts I have on my journal. All I needed to do, was add code to find the most viewed posts out of all posts.
- Finding the most viewed posts means sorting the list by view count and then returning the top X amount of posts. Both of those actions, I had to learn how to do in Python. Fun stuff.
- I also had to learn how to typecast a
string
into anint
in Python. Note, that in Python, you wrap the parenthesis on the object you are casting, not on the data type you want to cast it to. Minor syntax difference compared to typecasting in C#, but it won't work unless you get it right. - Next I had to learn how to display the posts on a webpage as soon as I open the app. This was noteworthy because the original Search app was designed to work with two webpages; a Search page and a Search Results page. For this app, I needed to show the Search Results page as soon as I open the app. To do this, I tinkered with the code by commenting out a bunch of stuff and running the app to see what would happen. I didn't know what I was doing most of the time, but that was what made it all the more fun for me. I'm so used to working with C# and .NET where I have an idea of what will happen just by looking at the code. It was a fun change of pace to work with something where, I had no idea what would happen if I comment out lines of code.
- Lastly, I decided to clean up all my Inline CSS and learned how to use Internal CSS instead. Okay, it wasn't really that I didn't know how to style a webpage using Internal CSS, but it was more about the fact that I've never had to style a webpage using Internal CSS, ever. Not even in my work as a software developer. So, I just wanted some real world practice with it.
Some links to pages that helped me get it done:
- Sorting Mini-HOW TO
- How to Sort a List, Tuple or Object (with sorted) in Python
- How to get top 5 objects from an array in Python
- How to use comments in Python
- Python:Convert a String to a Number
- HTML Styles – CSS
Tags: #Bookmarks #Glitch #Python
Discuss... or leave a comment below.