music-app (no spaces!)You are now on the github repository of your new app.
The future is yours!
Check out the url of your repository. It should look like this: https://github.com/YOUR-USERNAME/music-app\
You see just one file : README.md
https://github.com/YOUR-USERNAME/music-app. key (period/dot) on your keyboard
.com to .dev in the URL: https://github.dev/YOUR-USERNAME/music-appThis is where you edit the code.
on the left you have multiple icons. each gives you access to different features of github.dev
we will use :
In the middle you have the code editor where you edit your code.
In the following I use the World Music Hits Dataset. See the description here
download the file from here
and drag drop it into the file explorer in the githb.dev editor
requirements.txtstreamlit
pandas
plotly
Ctrl+S / Cmd+S to saveapp.pyimport streamlit as st
import pandas as pd
import plotly.express as px
# Title
st.title("šµ Music Data Explorer")
# Load data
df = pd.read_csv('WorldHits.csv')
# Let user select which column to plot
column = st.selectbox(
"Select a feature to plot over time:",
['energy', 'danceability', 'loudness', 'tempo', 'valence']
)
# Create the line chart
fig = px.line(
df.groupby('year')[column].mean().reset_index(),
x='year',
y=column,
title=f'{column.capitalize()} Over Time'
)
# Display the chart
st.plotly_chart(fig)
Ctrl+S / Cmd+S to saveThat's it! This simple app:
Add music apphttps://github.com/YOUR-USERNAME/music-appREADME.mdapp.pyWorldHits.csvrequirements.txtNow we need to deploy your app. For that we need to create a Streamlit Cloud account.
Now the deploy part so that the website is live! and everyone can access it on the world wide web.
YOUR-USERNAME/music-appmainapp.pyYour app URL: https://YOUR-USERNAME-music-app-RANDOM.streamlit.app
What you see:
Let's add one more line to show the data:
https://github.dev/YOUR-USERNAME/music-appapp.pyst.write(f"Average {column}: {df[column].mean():.2f}")
Ctrl+S / Cmd+S to saveAdd average displayWrite Code ā Save ā Commit ā Push ā Auto Deploy
Every time you push to GitHub, Streamlit Cloud automatically rebuilds your app!
App won't load?
app.py, WorldHits.csv, requirements.txtError in app?
app.pyā Created GitHub account ā Created repository ā Wrote 20 lines of Python code ā Committed and pushed code ā Deployed live web app ā Made a change and redeployed
Core lesson: Write ā Commit ā Push ā Deploy ā Repeat
in chatgpt write teh following prompt
This is the code for a simple streamlit app
https://github.com/SkatAI/music-app-01
The repo is open
I want to compare key metrics by Key (ythe musical key of the track)
Your task: modify the app.py code
- keep current visualization
- user selects a feature: from ['energy', 'danceability', 'loudness', 'tempo', 'valence'] and 'duration'
- User sees box plots per key for selected feature
IMPORTANT:
- Keep code super simple
- Do not optimize
- No error handling
- this is a quick demo not production code
- write the whole app.py code with modifications
the new code generated by chatgpt is
import streamlit as st
import pandas as pd
import plotly.express as px
# Title
st.title("Music Data Explorer")
# Load data
df = pd.read_csv("WorldHits.csv")
# Feature selector (added Duration)
feature = st.selectbox(
"Select a feature:",
["energy", "danceability", "loudness", "tempo", "valence", "duration"]
)
# --- Keep current visualization: line chart of yearly average ---
fig_line = px.line(
df.groupby("year")[feature].mean().reset_index(),
x="year",
y=feature,
title=f"{feature} Over Time (Yearly Average)"
)
st.plotly_chart(fig_line, use_container_width=True)
# --- New visualization: box plots by musical key ---
fig_box = px.box(
df,
x="key",
y=feature,
points="all",
title=f"{feature} by Musical Key"
)
st.plotly_chart(fig_box, use_container_width=True)
Copy this code and paste it in the app.py file in the github.dev editor, replacing the original code.
Then click on the source code icon and commit the changes
Go to the app url, it should reload automatically after a few seconds
if nothing happens, go to your github repo and check that the code was actually modified
You should see the message you just typed in github.dev as the last commit.
If you have an error, copy it, paste it in chatgpt and ask for a fix