+ 3

how to count number of likes?

I have extracted data from a json api and implemented a button to like each item using cookies. how do I count the number of likes so that I can display the top 10 liked items?

17th Apr 2021, 6:00 PM
Xixi
6 ответов
+ 3
Xixi You're welcome. Have you written any server code before? If you have, it might be good to go with that since you already know some. If you haven't, I'd recommend Node since you obviously already know some JavaScript. Python might be a good option because like Node/JavaScript, it has a big community. I don't really know Python but it's supposed to be fairly quick to learn the basics. Another couple of candidates are PHP and Ruby on Rails.
17th Apr 2021, 10:26 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 2
Jan Markus I like the way you think.
17th Apr 2021, 7:05 PM
zxtychj
zxtychj - avatar
+ 2
CamelBeatsSnake thanks do you have any suggestions which language to implement the server side in?
17th Apr 2021, 10:03 PM
Xixi
+ 2
Xixi Cool. Look into web frameworks for Python like Django. There are lots of them but Django is very widely used from what I know. There's also Flask which is more lightweight but very quick to set up, and Web2Py might be worth looking at.
17th Apr 2021, 10:42 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 1
It sounds like you need to store some state. It sounds like you need a feature where you need to know about all the likes from all your users, then use that data to generate a ranking that all users can see. If I'm right in thinking that's why you want to do, you'll need your own server side solution. Basically, it can't just be a client-side solution because you need to send out the ranking info to all your users. One approach is every time any user presses like on any item, a request is made to an API which handles adding the like to the item. When the application loads in the client (browser), it'll have to make a request to get all the like data so that it can display them in the right order according to the ranking.
17th Apr 2021, 6:18 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 1
CamelBeatsSnake ooh ok. thanks a lot! I'll look into those I know python but haven't done any for the purposes of web dev
17th Apr 2021, 10:29 PM
Xixi