Spaces:
Runtime error
Runtime error
pauldechorgnat commited on
Commit ·
380ec2b
1
Parent(s): 28bcf8a
Adding check_url_input function
Browse files
app.py
CHANGED
|
@@ -4,9 +4,33 @@ st.title("Exemple de titrage automatique")
|
|
| 4 |
|
| 5 |
url_input = st.text_input(
|
| 6 |
label="Entrez l'URL d'une décision sur le site de la cour de cassation",
|
|
|
|
| 7 |
)
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
judilibre_id = url_input.split("/")[-1]
|
| 11 |
|
| 12 |
-
st.subtitle(f"La décision choisie est {url_input}")
|
|
|
|
| 4 |
|
| 5 |
url_input = st.text_input(
|
| 6 |
label="Entrez l'URL d'une décision sur le site de la cour de cassation",
|
| 7 |
+
placeholder="https://www.courdecassation.fr/decision",
|
| 8 |
)
|
| 9 |
|
| 10 |
+
|
| 11 |
+
def check_url_input(url):
|
| 12 |
+
url_splits = url.split("/")
|
| 13 |
+
|
| 14 |
+
# checking the URL
|
| 15 |
+
if len(url_splits) != 5:
|
| 16 |
+
return False
|
| 17 |
+
if url_splits[0] != "https:":
|
| 18 |
+
return False
|
| 19 |
+
if url_splits[2] not in ["www.courdecassation.fr", "courdecassation.fr"]:
|
| 20 |
+
return False
|
| 21 |
+
if url_splits[3] != "deicsion":
|
| 22 |
+
return False
|
| 23 |
+
|
| 24 |
+
# checking the judilibre id
|
| 25 |
+
try:
|
| 26 |
+
int(url_splits[4], base=16)
|
| 27 |
+
except ValueError:
|
| 28 |
+
return False
|
| 29 |
+
|
| 30 |
+
return True
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
if check_url_input(url_input):
|
| 34 |
judilibre_id = url_input.split("/")[-1]
|
| 35 |
|
| 36 |
+
st.subtitle(f"La décision choisie est {url_input}")
|