ARaffay01 commited on
Commit
3cc27e8
·
verified ·
1 Parent(s): 0f97d24

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import qrcode
3
+
4
+ # Set the title of the Streamlit app
5
+ st.title("Hugging Face QR Code Generator")
6
+
7
+ # Allow the user to choose between generating a QR code for a model or a dataset
8
+ type_choice = st.radio("Select type:", ("Model", "Dataset"))
9
+
10
+ # Text input for the user to enter the model or dataset identifier
11
+ identifier = st.text_input("Enter the identifier:")
12
+
13
+ # Check if the user has entered an identifier
14
+ if identifier:
15
+ # Construct the URL based on the selected type
16
+ if type_choice == "Model":
17
+ url = f"https://huggingface.co/{identifier}"
18
+ else: # Dataset
19
+ url = f"https://huggingface.co/datasets/{identifier}"
20
+
21
+ # Generate the QR code from the URL
22
+ img = qrcode.make(url)
23
+
24
+ # Display the QR code in the app with a caption
25
+ st.image(img, caption=f"Scan this QR code to visit the {type_choice.lower()} page")
26
+
27
+ # Show the URL that the QR code links to for verification
28
+ st.write(f"This QR code links to: {url}")
29
+ else:
30
+ # Prompt the user to enter an identifier if the input is empty
31
+ st.write("Please enter an identifier to generate the QR code.")