Update main.py
Browse files
main.py
CHANGED
@@ -1,65 +1,20 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
from
|
4 |
-
from loading_file import precomputed_df, generate_pdf
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
|
9 |
-
#
|
10 |
-
|
11 |
-
st.write("Opening backup link...")
|
12 |
-
st.markdown('<a href="https://ireland.streamlit.app/" target="_blank">Click here</a>', unsafe_allow_html=True)
|
13 |
|
14 |
-
#
|
15 |
-
st.title("Visa Application Search")
|
16 |
-
|
17 |
-
# Debugging: Show Data Preview
|
18 |
-
if not precomputed_df.empty:
|
19 |
-
st.write("### Debugging: Data Loaded")
|
20 |
-
st.dataframe(precomputed_df.head(10)) # Display first 10 rows
|
21 |
-
|
22 |
-
# **Search Application by Number**
|
23 |
application_number = st.text_input("Enter Application Number:")
|
24 |
-
search_button = st.button("Search")
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
if application_number
|
29 |
-
|
30 |
-
|
31 |
-
result_df = precomputed_df[precomputed_df["Application Number"] == application_number]
|
32 |
-
|
33 |
-
if not result_df.empty:
|
34 |
-
st.write("### Search Result:")
|
35 |
-
st.dataframe(result_df)
|
36 |
-
else:
|
37 |
-
st.warning("No results found.")
|
38 |
-
except ValueError:
|
39 |
-
st.warning("Please enter a valid numeric application number.")
|
40 |
else:
|
41 |
-
st.warning("Please enter
|
42 |
-
|
43 |
-
# **Place Download Buttons BELOW the Search Button**
|
44 |
-
if not precomputed_df.empty:
|
45 |
-
st.write("## Download Full Decision List")
|
46 |
-
|
47 |
-
# Excel Download
|
48 |
-
excel_buffer = BytesIO()
|
49 |
-
precomputed_df.to_excel(excel_buffer, index=False, engine="openpyxl")
|
50 |
-
excel_buffer.seek(0)
|
51 |
-
st.download_button(
|
52 |
-
label="Download Excel File",
|
53 |
-
data=excel_buffer,
|
54 |
-
file_name="Visa_Decisions.xlsx",
|
55 |
-
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
56 |
-
)
|
57 |
-
|
58 |
-
# PDF Download
|
59 |
-
pdf_buffer = generate_pdf(precomputed_df, "Visa Decisions")
|
60 |
-
st.download_button(
|
61 |
-
label="Download PDF File",
|
62 |
-
data=pdf_buffer,
|
63 |
-
file_name="Visa_Decisions.pdf",
|
64 |
-
mime="application/pdf",
|
65 |
-
)
|
|
|
1 |
import streamlit as st
|
2 |
+
from loading_file import fetch_data
|
3 |
+
from search import search_application
|
|
|
4 |
|
5 |
+
# Fetch data and store it in df
|
6 |
+
df = fetch_data()
|
7 |
|
8 |
+
# Title for the Streamlit app (Move this to the top)
|
9 |
+
st.title("Visa Application Status Checker")
|
|
|
|
|
10 |
|
11 |
+
# Streamlit UI to input the application number
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
application_number = st.text_input("Enter Application Number:")
|
|
|
13 |
|
14 |
+
# Add a search button that triggers the search only when clicked
|
15 |
+
if st.button("Search"):
|
16 |
+
if application_number:
|
17 |
+
# Call the search_application function with both application number and df
|
18 |
+
search_application(application_number, df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
else:
|
20 |
+
st.warning("Please enter an Application Number to search.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|