Bday / app.py
DS2's picture
Create app.py
dca4007 verified
raw
history blame
3.34 kB
import streamlit as st
import numpy as np
import time
import random
# Add the JavaScript and CSS code
st.set_page_config(layout="wide")
st.write("""
<style>
body {
background-color: black;
overflow: hidden;
margin: 0;
padding: 0;
}
.star {
position: absolute;
width: 4px;
height: 4px;
background-color: white;
border-radius: 50%;
box-shadow: 0 0 10px white;
animation: twinkle 2s infinite;
}
@keyframes twinkle {
0% {
opacity: 1;
}
50% {
opacity: 0.5;
}
100% {
opacity: 1;
}
}
.planet {
position: absolute;
width: 50px;
height: 50px;
background-color: #ccc;
border-radius: 50%;
animation: orbit 10s linear infinite;
}
@keyframes orbit {
0% {
transform: translate(-50%, -50%) rotate(0deg) translateX(200px) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg) translateX(200px) rotate(-360deg);
}
}
.astronaut {
position: absolute;
width: 50px;
height: 50px;
background-image: url('https://via.placeholder.com/50');
background-size: contain;
animation: float 5s infinite ease-in-out;
}
@keyframes float {
0% {
transform: translateY(0);
}
50% {
transform: translateY(20px);
}
100% {
transform: translateY(0);
}
}
.flower {
position: absolute;
width: 30px;
height: 30px;
background-image: url('https://images.app.goo.gl/EJVhnVnoJtDV7iMQA');
background-size: contain;
animation: fall 5s linear infinite;
}
@keyframes fall {
0% {
transform: translateY(0);
opacity: 1;
}
100% {
transform: translateY(100vh);
opacity: 0;
}
}
</style>
""", unsafe_allow_html=True)
# Add the stars
num_stars = 300
for _ in range(num_stars):
x = random.randint(0, st.session_state.get('width', 1920))
y = random.randint(0, st.session_state.get('height', 1080))
st.markdown(f'<div class="star" style="left: {x}px; top: {y}px;"></div>', unsafe_allow_html=True)
# Add the planets
num_planets = 5
for _ in range(num_planets):
x = random.randint(0, st.session_state.get('width', 1920))
y = random.randint(0, st.session_state.get('height', 1080))
st.markdown(f'<div class="planet" style="left: {x}px; top: {y}px;"></div>', unsafe_allow_html=True)
# Add the astronaut
x = random.randint(0, st.session_state.get('width', 1920))
y = random.randint(0, st.session_state.get('height', 1080))
st.markdown(f'<div class="astronaut" style="left: {x}px; top: {y}px;"></div>', unsafe_allow_html=True)
# Add the flowers
num_flowers = 50
for _ in range(num_flowers):
x = random.randint(0, st.session_state.get('width', 1920))
y = random.randint(0, 0)
st.markdown(f'<div class="flower" style="left: {x}px; top: {y}px;"></div>', unsafe_allow_html=True)
# Add the YouTube video
st.markdown(
"""
<div style="display: flex; justify-content: center; align-items: center; height: 60vh;">
<div style="width: 80%;">
<iframe width="100%" height="515" src="https://www.youtube.com/embed/prmmCg5bKxA?si=ea58nLNlyhcI8BKI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
""",
unsafe_allow_html=True
)