Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Function to parse the text file
|
4 |
+
def parse_data(filename):
|
5 |
+
with open(filename, "r") as file:
|
6 |
+
lines = file.readlines()
|
7 |
+
|
8 |
+
categories = {}
|
9 |
+
current_category = None
|
10 |
+
|
11 |
+
for line in lines:
|
12 |
+
line = line.strip()
|
13 |
+
if not line:
|
14 |
+
continue
|
15 |
+
if line.startswith('Best'):
|
16 |
+
current_category = line
|
17 |
+
categories[current_category] = []
|
18 |
+
else:
|
19 |
+
categories[current_category].append(line)
|
20 |
+
|
21 |
+
return categories
|
22 |
+
|
23 |
+
# Function to create a search URL
|
24 |
+
def create_search_url(artist_song):
|
25 |
+
base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
|
26 |
+
return base_url + artist_song.replace(' ', '+').replace('β', '%E2%80%93')
|
27 |
+
|
28 |
+
# Parsing the data
|
29 |
+
data = parse_data("requiredData.txt")
|
30 |
+
|
31 |
+
# Streamlit page configuration
|
32 |
+
st.set_page_config(page_title="MTV VMAs 2023 Awards", layout="wide")
|
33 |
+
|
34 |
+
# Main title
|
35 |
+
st.title("π Video Awards Presentation Streamlit for 2023!")
|
36 |
+
|
37 |
+
# Displaying data
|
38 |
+
for category, nominees in data.items():
|
39 |
+
st.header(f"{category} πΆ")
|
40 |
+
with st.expander("View Nominees"):
|
41 |
+
for nominee in nominees:
|
42 |
+
col1, col2 = st.columns([3, 1])
|
43 |
+
with col1:
|
44 |
+
st.markdown(f"* {nominee}")
|
45 |
+
with col2:
|
46 |
+
st.markdown(f"[Wikipedia]({create_search_url(nominee)})")
|
47 |
+
|
48 |
+
# Footer
|
49 |
+
st.caption("Source: MTV Video Music Awards 2023")
|