-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.py
70 lines (59 loc) · 1.93 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import streamlit as st
from st_pages import show_pages_from_config
import time
import os
import sys
import requests
from Services.createNewCompany import addNewCompany
def is_valid_url(url):
try:
response = requests.head(url)
response.raise_for_status() # Raises an exception for non-2xx status codes
return True
except requests.exceptions.RequestException:
return False
# declaring custom css for the webpage
css = """
<style>
.stButton>button {
width: 100px;
height: 25px;
font-size: 15px;
}
.css-q8sbsg p{
font-size: 20px;
}
</style>
"""
st.set_page_config(page_title="LinkedIn jobs", page_icon="favicon.ico")
st.markdown(css, unsafe_allow_html=True,)
st.subheader("Add new company")
# taking input of new companies
with st.form("url_input"):
st.text(
"The link format should be ' https://www.linkedin.com/company/<companyname>'")
new_company_url = st.text_input(
"Enter the linkedin url of the company", "")
submitted = st.form_submit_button("Add")
if submitted:
if is_valid_url(new_company_url):
result = addNewCompany(new_company_url)
if result:
success_placeholder = st.empty()
success_placeholder.success(
"new_company" + " added on the sidebar " + "!")
time.sleep(2)
success_placeholder.empty()
else:
warning_placeholder = st.empty()
warning_placeholder.warning(
"No jobs in the given company at the moment!")
time.sleep(2)
warning_placeholder.empty()
else:
failure_placeholder = st.empty()
e = RuntimeError("Please provide a valid url!")
failure_placeholder.exception(e)
time.sleep(1)
failure_placeholder.empty()
show_pages_from_config()