ayeshaishaq004 commited on
Commit
a79a79d
·
verified ·
1 Parent(s): 7b0d685

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from PIL import Image
4
+
5
+ # Streamlit app configuration
6
+ st.set_page_config(page_title='Phishing URL Detection', layout='centered')
7
+
8
+ # App Header
9
+ st.markdown("""
10
+ <style>
11
+ body { background-color: #f0f2f6; }
12
+ .main { background-color: white; padding: 2rem; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
13
+ </style>
14
+ """, unsafe_allow_html=True)
15
+
16
+ st.title('🔍 Phishing URL Detection App')
17
+ st.write('Enter a URL to check if it is Phishing or Legitimate.')
18
+
19
+ # Display an illustrative image (Optional)
20
+ image = Image.open("phishing_warning.png") # Add a relevant image in your working directory
21
+ st.image(image, use_column_width=True)
22
+
23
+ # Input URL from the user
24
+ url_input = st.text_input('Enter URL:', '')
25
+
26
+ # Hugging Face model endpoint
27
+ API_URL = 'https://huggingface.co/ayeshaishaq004/website-url-classifier/resolve/main/phishing_model.pkl' # Replace with your model URL
28
+
29
+ if st.button('Check URL'):
30
+ if url_input:
31
+ try:
32
+ # Sending URL to model for prediction
33
+ response = requests.post(API_URL, json={'url': url_input})
34
+ prediction = response.json().get('prediction', 'Error: Could not get prediction')
35
+
36
+ if prediction == 'Phishing':
37
+ st.error('🚨 This URL is likely a **Phishing Site**. Be careful!')
38
+ elif prediction == 'Legitimate':
39
+ st.success('✅ This URL is likely **Legitimate**.')
40
+ else:
41
+ st.warning('⚠️ Unable to determine. Try again later.')
42
+
43
+ except Exception as e:
44
+ st.error(f'Error: {e}')
45
+ else:
46
+ st.warning('Please enter a valid URL.')