Music recommender web service (Flask and Celery)
As the machine learning part has been discussed here, in this article I am going to explain the process of using that recommender engine.
This article is based on this repo.
Celery
First the recommender function is going to be benefited asynchronous feature of celery.
Flask
In order to deploy the engine, flask framework is employed for that. Here is main app, resources and runner of application.
SQLAlchemy
In order to save the data into postgresql, sqlalchemy is used as ORM for our flask application.
Build and Run
All the services has been dockerized and could easily be built.
docker-compose up --build -d
Try to build application with this command.
The admin panel is here:
http://localhost:8000/admin
Get some similar music
http://localhost:8000/recommend/sexual eruption/snoop dogg/4
By going to browser, this url will bring 4 song similar to sexual eruptionby snoop dogg:
{"for":"music: sexual eruption, artist: snoop dogg","ip_address":"192.168.128.1","musics":
[{"1":{"artist":"boys noize","song":"oh! (a-trak remix)","spotify_url":
"https://open.spotify.com/track/5fai3huhzsk4foq7s3g5ll"}},
{"2":{"artist":"paris hilton","song":"nothing in this world","spotify_url":
"https://open.spotify.com/track/4xrgwyaarl21fesc6bvlif"}},
{"3":{"artist":"bonde do rol\u00ea","song":"james bonde","spotify_url":
"https://open.spotify.com/track/1f6goknk0i9m3pq1kancaf"}},
{"4":{"artist":"the valentinos","song":"kafka (bag raiders remix)","spotify_url":
"https://open.spotify.com/track/0oclk8vnbtefvxxcb7tspw"}}],"status":200}
Not bad result:))