Gowthamvemula commited on
Commit
e8d7864
·
verified ·
1 Parent(s): 3dbf88e

Create bg_utils.py

Browse files
Files changed (1) hide show
  1. bg_utils.py +19 -0
bg_utils.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import base64
3
+
4
+ def set_background(image_file):
5
+ with open(image_file, "rb") as img:
6
+ encoded_image = base64.b64encode(img.read()).decode()
7
+ st.markdown(
8
+ f"""
9
+ <style>
10
+ .stApp {{
11
+ background-image: url("data:image/jpg;base64,{encoded_image}");
12
+ background-size: cover;
13
+ background-repeat: no-repeat;
14
+ background-attachment: fixed;
15
+ }}
16
+ </style>
17
+ """,
18
+ unsafe_allow_html=True
19
+ )