chagu-demo / app.py
talexm
building app category 4
7405474
raw
history blame
1.74 kB
import streamlit as st
import os
from PIL import Image
from chainguard.blockchain_logger import BlockchainLogger
# Initialize Blockchain Logger
blockchain_logger = BlockchainLogger()
def log_metadata(file_name, tags, album):
"""Log photo metadata to Chagu blockchain."""
metadata = {
"file_name": file_name,
"tags": tags,
"album": album
}
block_details = blockchain_logger.log_data(metadata)
return block_details
# Streamlit App Layout
st.title("Memora: Photo & Video Uploader")
st.subheader("Securely upload and organize your memories")
# File Upload
uploaded_files = st.file_uploader(
"Upload your photos or videos", accept_multiple_files=True, type=['jpg', 'jpeg', 'png', 'mp4', 'avi']
)
if uploaded_files:
for uploaded_file in uploaded_files:
# Display uploaded file
st.write(f"File Name: {uploaded_file.name}")
if uploaded_file.type.startswith('image'):
image = Image.open(uploaded_file)
st.image(image, caption=uploaded_file.name, use_column_width=True)
# Metadata Input
album = st.text_input(f"Album for {uploaded_file.name}", value="Default Album")
tags = st.text_input(f"Tags for {uploaded_file.name} (comma-separated)", value="")
# Log Metadata
if st.button(f"Log Metadata for {uploaded_file.name}"):
metadata = log_metadata(uploaded_file.name, tags.split(','), album)
st.write(f"Metadata logged successfully! Block Details: {metadata}")
# Display Blockchain Validation
if st.button("Validate Blockchain Integrity"):
is_valid = blockchain_logger.is_blockchain_valid()
st.write("Blockchain Integrity:", "Valid βœ…" if is_valid else "Invalid ❌")