Let's take a quick look at the .py
files in the repl; most of it should look familiar, or similar to what we've seen before.
main.py
serves a flask
app with a single page, and does some processing for POST
requestsauth.py
has somewhere to put an access_token
should we want tomixtape.py
contains tracks_detail
, which is imported into main.py
and used by render_template()
tracks.py
has functions to fetch data from the Spotify API, and to extract summary information from itvotes.py
has reset_votes()
and log_user_choice()
functions, which modify the replit
databaseflask
app will use the index.html
template to create our pagebase.html
index.html
uses {% include ... }
to incorporate top_section.html
and tracks_section.html
top_section
has no Jinja templating logic, i.e. dynamic elements to ittracks_section
has Jinja statements for the voting buttons but not track informationFirst of all, work in mixtape.py
:
tracks.get_track_data()
function with a valid access_token
and some track_id
s of your choice to fetch data from Spotify (six is a good number of tracks)replit
database so it can be retrieved in future without needing to request from the API againtracks.track_summary()
to extract data to display on the page, assigning it to tracks_detail
Then, work in tracks_section.html
:
Finally, see if you can add some different styling to the app. We'll take a look at how to do this now.
You'll notice in base.html
that several stylesheets are imported, and that these can be found in the /static
folder.
bootstrap.css
was generated using the bootstrap.build service, using the Sandstone theme_variables.scss
file allows you to retainany customizations made with the toolalbum.css
custom.css
includes some further customizations, to fonts and the design of the cardsTake a look at custom.css
; at the top you'll see several @import
statements, and then references to the imported fonts in the font-family
attributes of some of the CSS class declarations:
h1, h2 {
font-family: 'Rock Salt', cursive;
...
}
@import
statements and associated font-family
values for numerous other fonts from Google Fontsh1, h2 {
...
color: var(--dark);
}
--dark
color (defined in and inherited from bootstrap.css
)