This is a utility app for Spotify with personalised recommendations based on our algorithm for song recommendation. It will also provide you different kind of insights into your listening behaviour.
- Clone the repository in your machine using
git clone
musixpedia/ |__.env |__requirements.txt |__run.py |__server.wsgi |__README.md |__app/ |____init__.py |__home.py |__utils.py |__static/ |__templates/ |__index.html |__home.html |__layout.html
- Create a
.env
file (at musixpedia/.env) inside musixpedia repository containing below environment variablesif you are running on development server, add below line as well in theexport SPOTIPY_CLIENT_ID='your client id' export SPOTIPY_CLIENT_SECRET='your client secret' export SPOTIPY_REDIRECT_URI='redirect uri' export FLASK_APP='app/home.py' export FLASK_ENV=development
.env
export FLASK_ENV=development
- Install requirements from
requirements.txt
pip install -r requirements.txt
- Now go to musixpedia directory and run below command:
or
flask run
python run.py
After following above steps you should see the output similar to below
> Serving Flask app "app" (lazy loading)
> Environment: development
> Debug mode: on
> Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
> Restarting with stat
> Debugger is active!
> Debugger PIN: 152-577-664
Always keep your redirect uri at a different port then application port to make login with spotify work. Like in this example
application_url = http://127.0.0.1:5000/
redirect_url = http://127.0.0.1:8080/
Otherwise, if you keep them at the same port, you will get an error saying Address already in use and your login will fail.
- Installation of required linux packages.
sudo apt-get remove --purge apache2 apache2-data apache2-utils sudo apt-get install apache2 sudo apt-get install python3-pip sudo pip3 install virtualenv sudo apt-get install libapache2-mod-wsgi-py3
- Check the installation of apache2 by below command. It should be in running status and should return the standard
index.html
athttp://localhost
.You can stop/restart/start the apache2 service with below commandssudo /etc/init.d/apache2 status
orsudo /etc/init.d/apache2 status sudo /etc/init.d/apache2 restart sudo /etc/init.d/apache2 start sudo /etc/init.d/apache2 stop
sudo systemctl status apache2.service sudo systemctl reload apache2.service sudo systemctl stop apache2.service sudo systemctl start apache2.service
- Install python specific packages
sudo virtualenv venv source venv/bin/activate sudo pip3 install -r requirements.txt deactivate
- Set up required environement variables in
/etc/apache2/envvars
.export SPOTIPY_CLIENT_ID='your client id' export SPOTIPY_CLIENT_SECRET='your client secret' export SPOTIPY_REDIRECT_URI='redirect uri'
- Clone the code at
/var/www/musixpedia/
/var/www/musixpedia/ |__requirements.txt |__run.py |__server.wsgi |__README.md |__app/ |____init__.py |__home.py |__utils.py |__static/ |__templates/ |__index.html |__home.html |__layout.html
- Configure a new application with apache2
Add below configurations in the conf file. Replace relevant values according to your environment.
sudo nano /etc/apache2/sites-available/musixpedia sudo nano /etc/apache2/sites-available/musixpedia.conf
Then, reload your apache2 instance.<VirtualHost *:80> ServerName localhost ServerAdmin [email protected] WSGIDaemonProcess python-path=/home/arpit/anaconda3/bin/python/site-packages WSGIScriptAlias / /var/www/musixpedia/server.wsgi <Directory /var/www/musixpedia/app/> Order allow,deny Allow from all </Directory> Alias /static /var/www/musixpedia/app/static <Directory /var/www/musixpedia/app/static/> Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Now, you should be able to see the site atsudo service apache2 restart sudo systemctl reload apache2.service
http://localhost/
- You can find the error/service/access logs at
/var/log/apache2/
- Give owner permissions to
APACHE_RUN_USER
&APACHE_RUN_GROUP
tomusixpedia/.cache/*
folder to be able to manage access tokens easily. Username forAPACHE_RUN_USER
&APACHE_RUN_GROUP
can be found in/etc/apache2/envvars
file.
- URI redirect for spotify login is not working in apache mode. Error: Address already in use.
- Add new features to make this site useful.