LilRg commited on
Commit
1727bbe
·
verified ·
1 Parent(s): 22dc1a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -2,6 +2,7 @@ import requests
2
  import json
3
  import gradio as gr
4
  import logging
 
5
 
6
  logging.basicConfig(level=logging.ERROR)
7
  logger = logging.getLogger(__name__)
@@ -16,18 +17,16 @@ YOUR_APP_NAME = "MonChatbot"
16
 
17
  # ID de l'étudiant
18
  #student_id = 34
19
- current_request = None
20
 
21
- def getParams(x):
22
- global current_request
23
- params = current_request.query_params
24
 
25
- if 'id' in params:
26
- return params['id']
27
- else:
28
- return None
29
-
30
- student_id = getParams(None)
31
 
32
  def get_user_info_by_id(student_id):
33
  url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"
 
2
  import json
3
  import gradio as gr
4
  import logging
5
+ from urllib.parse import urlparse, parse_qs
6
 
7
  logging.basicConfig(level=logging.ERROR)
8
  logger = logging.getLogger(__name__)
 
17
 
18
  # ID de l'étudiant
19
  #student_id = 34
20
+ url = "https://huggingface.co/spaces/LilRg/AlbatrossV1Chatbot/?id={LOGGED_IN_USER:ID}"
21
 
22
+ # Parse l'URL
23
+ parsed_url = urlparse(url)
 
24
 
25
+ # Récupérer les paramètres de la requête
26
+ query_params = parse_qs(parsed_url.query)
27
+
28
+ # Récupérer l'ID
29
+ student_id = query_params.get('id', [None])[0]
 
30
 
31
  def get_user_info_by_id(student_id):
32
  url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"