teacherc / spheri-app

Spheri is a simple web app that recommends a song based on your local weather

Home Page:https://www.spheri.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PythonFlaskBootstrapGoogle CloudVisual Studio CodeMarkdown Spotify BlackLicense: GPL v3 Self-taught

spheri.app

Table of Contents

Description

A blog post about how I'd refactor Spheri

Spheri is a web app that uses local weather information to generate song recommendations. Someone experiencing thundersnow can expect a different recommendation than someone experiencing clear conditions at 72℉.

Link to the deployed web app: https://spheri.app/

Alternative link: https://spheri.uk.r.appspot.com/

Link to r/Python post (500+ upvotes, 80 comments!): https://www.reddit.com/r/Python/comments/zb6ro9/i_got_laid_off_in_midoctober_and_decided_to_teach/

Motivation

I was the ten-year-old who begged to stay up past 11 pm so I could watch meteorologist Steve Pool talk about El Niño, dew points, and the jet stream. Even though I did not take up meterology as an adult, the weather has a big impact on my mood. I wanted to create something that would help me find new music that matches whatever weather vibes I'm experiencing.

This app solves a problem my wife and I have. There is so much music on Spotify, that it's hard to choose which new songs to listen to. I find myself listening to the same playlists over and over again.

Learning

I also built this project so I could cement my Python, Flask, git/GitHub, Bootstrap, APIs, unit testing, and Google Cloud deployment skills.

Repo Overview

├── LICENSE.txt
├── Dockerfile
├── README.md
├── .github/workflows
│   └── ci.yml
├── app
│   ├── constants.py
│   ├── main.py
│   ├── requirements.txt
│   └── templates
│       ├── empty.html
│       ├── error.html
│       ├── form.html
│       └── layout.html
├── assets
│   └── images
│       └── recommendation.png
├── env.sample
├── requirements.txt
├── tests
│   └── test_main.py

Installation

If you want to see how the app looks to users, you can visit [http://spheri.app]

To run in a local environment:

  1. Fork the code
  2. Create and activate a Python virtual environment (if you need to install Python 3.x, visit [https://www.python.org/downloads/]):
$ python -m venv venv
$ source venv/bin/activate
  1. Update pip and install the required dependencies:
(venv) $ pip install -U pip
(venv) $ pip install -r requirements.txt
  1. Create a '''config.py''' file with the proper keys
CLIENT_ID=''
CLIENT_SECRET=''
ACCESS_KEY=''
CLIENT_ID=''
CLIENT_SECRET=''
  1. Start the Flask server:
(venv) $ python main.py
 * Serving Flask app "main" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 339-986-221
  1. Open a browser to the specified local address and port (Usually http://127.0.0.1:8080/). Voila!

Tests

Tests are located in tests/test_main.py. After you create your virtual environment and install the required packages, you can run test_main.py.

Usage

A user can enter a valid U.S. zipcode, submit the zipcode, and receive a readout of local weather conditions as well as a song recommendation (via Spotify's recommendation API). A 30-second preview of the song can be accessed via the player. If a user clicks on the album art or the artist link, the corresponding Spotify track page will open.

screenshot of Spheri recommendation

Credits

Useful links:

License

GNU General Public License v3.0 [https://choosealicense.com/licenses/gpl-3.0/]

About

Spheri is a simple web app that recommends a song based on your local weather

https://www.spheri.app

License:GNU General Public License v3.0


Languages

Language:Python 61.2%Language:HTML 36.9%Language:Dockerfile 1.9%