Spaces:
Sleeping
Sleeping
import streamlit as st | |
import qrcode | |
# Set the title of the Streamlit app | |
st.title("Hugging Face QR Code Generator") | |
# Allow the user to choose between generating a QR code for a model or a dataset | |
type_choice = st.radio("Select type:", ("Model", "Dataset")) | |
# Text input for the user to enter the model or dataset identifier | |
identifier = st.text_input("Enter the identifier:") | |
# Check if the user has entered an identifier | |
if identifier: | |
# Construct the URL based on the selected type | |
if type_choice == "Model": | |
url = f"https://huggingface.co/{identifier}" | |
else: # Dataset | |
url = f"https://huggingface.co/datasets/{identifier}" | |
# Generate the QR code from the URL | |
img = qrcode.make(url) | |
# Display the QR code in the app with a caption | |
st.image(img, caption=f"Scan this QR code to visit the {type_choice.lower()} page") | |
# Show the URL that the QR code links to for verification | |
st.write(f"This QR code links to: {url}") | |
else: | |
# Prompt the user to enter an identifier if the input is empty | |
st.write("Please enter an identifier to generate the QR code.") |