| import streamlit as st | |
| import base64 | |
| def set_background(image_file): | |
| with open(image_file, "rb") as img: | |
| encoded_image = base64.b64encode(img.read()).decode() | |
| st.markdown( | |
| f""" | |
| <style> | |
| .stApp {{ | |
| background-image: url("data:image/jpg;base64,{encoded_image}"); | |
| background-size: cover; | |
| background-repeat: no-repeat; | |
| background-attachment: fixed; | |
| }} | |
| </style> | |
| """, | |
| unsafe_allow_html=True | |
| ) |