Upload 2 files
Browse files- app.py +74 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
import pandas as pd
|
4 |
+
import base64
|
5 |
+
import uuid
|
6 |
+
import requests
|
7 |
+
|
8 |
+
st.set_page_config(layout="wide")
|
9 |
+
|
10 |
+
hide_streamlit_style = """
|
11 |
+
<style>
|
12 |
+
#MainMenu {visibility: hidden;}
|
13 |
+
footer {visibility: hidden;}
|
14 |
+
</style>
|
15 |
+
"""
|
16 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
17 |
+
|
18 |
+
st.title('JotForm API Form Explorer')
|
19 |
+
st.markdown('This app allows you to view and download your JotForm forms using the JotForm API.')
|
20 |
+
|
21 |
+
st.sidebar.markdown('<img src="https://www.jotform.com/resources/assets/logo-nb/jotform-logo-transparent-800x200.png" alt="JotForm logo" width="200">', unsafe_allow_html=True)
|
22 |
+
|
23 |
+
st.sidebar.header('JotForm API Options')
|
24 |
+
|
25 |
+
api_url = st.sidebar.selectbox('API URL', ['api.jotform.com', 'custom'])
|
26 |
+
if api_url == 'custom':
|
27 |
+
custom_api_url = st.sidebar.text_input('Custom API URL', 'api.yourapi.com/API/')
|
28 |
+
api_url = custom_api_url.rstrip('/')
|
29 |
+
api_key = st.sidebar.text_input('Enter API Key', placeholder="API Key", value="")
|
30 |
+
limit = st.sidebar.slider('Form Limit', 100, 4000, 100, step=100)
|
31 |
+
orderby = st.sidebar.selectbox('Order By', ['id', 'username', 'title', 'status', 'created_at', 'updated_at', 'new', 'count', 'slug'])
|
32 |
+
status_filter = st.sidebar.selectbox('Status', ['All', 'ENABLED', 'DISABLED', 'DELETED'])
|
33 |
+
submit_button = st.sidebar.button('Submit')
|
34 |
+
if not submit_button:
|
35 |
+
st.write("Please Enter your API and select the criteria and click on the Submit Button.")
|
36 |
+
else:
|
37 |
+
st.empty()
|
38 |
+
|
39 |
+
st.sidebar.markdown("""Parameter | Description
|
40 |
+
--- | ---
|
41 |
+
apikey | Jotform User API Key. Get a new API Key [here](https://www.jotform.com/myaccount/api). If you have an Enterprise account, select 'custom' and enter your Enterprise JotForm API URL.
|
42 |
+
limit | Number of results in each result set for form list. Default is 100. Maximum is 4000.
|
43 |
+
orderby | Order results by a form field name: id, username, title, status(ENABLED, DISABLED, DELETED), created_at, updated_at, new (unread submissions count), count (all submissions count), slug (used in form URL).""")
|
44 |
+
|
45 |
+
|
46 |
+
if submit_button:
|
47 |
+
forms = []
|
48 |
+
for i in range(0, limit, 1000):
|
49 |
+
url = f'https://{api_url}/user/forms?apikey={api_key}&offset={i}&limit=1000&orderby={orderby}'
|
50 |
+
|
51 |
+
response = requests.get(url)
|
52 |
+
data = response.json()
|
53 |
+
|
54 |
+
if 'content' in data:
|
55 |
+
forms += data['content']
|
56 |
+
|
57 |
+
if forms:
|
58 |
+
df = pd.DataFrame(forms)
|
59 |
+
if status_filter != 'All':
|
60 |
+
df = df[df['status'] == status_filter]
|
61 |
+
st.table(df)
|
62 |
+
csv = df.to_csv(index=False)
|
63 |
+
b64 = base64.b64encode(csv.encode()).decode()
|
64 |
+
button_label = 'Download CSV file'
|
65 |
+
button_uuid = str(uuid.uuid4()).replace('-', '')
|
66 |
+
button_id = f'{button_label}-{button_uuid}'
|
67 |
+
button_html = f'<a download="forms.csv" href="data:file/csv;base64,{b64}" id="{button_id}" class="css-1p3ovfs e17oygji0"><button type="button" class="css-lc06hr e17oygji2"><span class="css-1ljozgh e17oygji1">{button_label}</span></button></a><style>.css-1p3ovfs.e17oygji0{{display: inline-block;}}.css-lc06hr.e17oygji2{{background-color: #f63366; color: white; border: none; cursor: pointer; padding: 8px 12px;}}.css-lc06hr.e17oygji2:hover{{background-color: #d80e41;}}</style>'
|
68 |
+
st.markdown(button_html, unsafe_allow_html=True)
|
69 |
+
else:
|
70 |
+
st.write('No forms found')
|
71 |
+
|
72 |
+
st.markdown("", unsafe_allow_html=True)
|
73 |
+
st.markdown("<hr style='text-align: center;'>", unsafe_allow_html=True)
|
74 |
+
st.markdown("<p style='text-align: center'><a href='https://github.com/Kaludii'>Github</a> | <a href='https://huggingface.co/Kaludi'>HuggingFace</a></p>", unsafe_allow_html=True)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastai==2.7.4
|
2 |
+
huggingface_hub[fastai]
|
3 |
+
fastcore>=1.3.27
|
4 |
+
base64
|