Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ 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,16 +18,18 @@ YOUR_APP_NAME = "MonChatbot"
|
|
| 17 |
|
| 18 |
# ID de l'étudiant
|
| 19 |
#student_id = 34
|
| 20 |
-
url = "https://huggingface.co/spaces/LilRg/ModificationCompetences?name={LOGGED_IN_USER:NAME}"
|
| 21 |
|
| 22 |
-
# Parse l'URL
|
| 23 |
-
parsed_url = urlparse(url)
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
def get_id_by_name(student_name):
|
| 32 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
import logging
|
| 5 |
from urllib.parse import urlparse, parse_qs
|
| 6 |
+
from gradio import Request
|
| 7 |
|
| 8 |
logging.basicConfig(level=logging.ERROR)
|
| 9 |
logger = logging.getLogger(__name__)
|
|
|
|
| 18 |
|
| 19 |
# ID de l'étudiant
|
| 20 |
#student_id = 34
|
|
|
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# 2. Solution recommandée pour Hugging Face Spaces
|
| 24 |
+
# Importation nécessaire
|
| 25 |
|
| 26 |
+
def get_user_info():
|
| 27 |
+
# Dans une fonction de votre interface Gradio
|
| 28 |
+
request = Request() # Obtient les informations de la requête actuelle
|
| 29 |
+
username = request.username # Récupère le nom d'utilisateur connecté
|
| 30 |
+
return username
|
| 31 |
+
|
| 32 |
+
student_name = get_user_info()
|
| 33 |
|
| 34 |
def get_id_by_name(student_name):
|
| 35 |
url = f"https://api.airtable.com/v0/{AIRTABLE_BASE_ID}/Inscription_Etudiants"
|