🚀 Add feature: Frontend app working stub
🚀 Add feature: Ruff linting 🚀 Add feature: Logging
This commit is contained in:
parent
41299d4bf1
commit
0f1a07da49
12 changed files with 234 additions and 22 deletions
62
frontend/app.py
Normal file
62
frontend/app.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
import os
|
||||
|
||||
import dotenv
|
||||
import requests
|
||||
import streamlit as st
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
# Set the backend API base URL
|
||||
BACKEND_URL = os.environ.get("BACKEND_URL")
|
||||
|
||||
# Database variables
|
||||
available_sources = requests.get(
|
||||
f"{BACKEND_URL}/import/available_sources"
|
||||
).json()
|
||||
|
||||
# Application tabs
|
||||
tabs = st.tabs(["Conversion", "Analysis", "Data", "Settings", "Dashboard"])
|
||||
|
||||
# Application core
|
||||
with tabs[0]:
|
||||
st.header("Conversion de source")
|
||||
with st.form("conversion_form"):
|
||||
input_file = st.file_uploader("Télécharge un fichier à convertir")
|
||||
input_text = st.text_area("Saisis du texte à convertir")
|
||||
source_type = st.selectbox(
|
||||
label="Sélectionne la source",
|
||||
options=[
|
||||
source.get("name")
|
||||
for source in available_sources.get("sources")
|
||||
],
|
||||
format_func=lambda x: {
|
||||
source.get("name"): source.get("display_name")
|
||||
for source in available_sources.get("sources")
|
||||
}.get(x),
|
||||
)
|
||||
if input_text:
|
||||
source_data = input_text
|
||||
elif input_file:
|
||||
source_data = input_file
|
||||
else:
|
||||
st.error("Tu dois fournir un fichier ou du texte")
|
||||
submitted = st.form_submit_button("Convertir")
|
||||
if submitted:
|
||||
response = requests.post(
|
||||
f"{BACKEND_URL}/convert",
|
||||
json={"source_type": source_type, "source_data": source_data},
|
||||
)
|
||||
st.success("Conversion Result:")
|
||||
st.write(response.json())
|
||||
|
||||
with tabs[1]:
|
||||
st.header("Importer des données")
|
||||
|
||||
with tabs[2]:
|
||||
st.header("Analyser des données")
|
||||
|
||||
with tabs[3]:
|
||||
st.header("Exporter des données")
|
||||
|
||||
with tabs[4]:
|
||||
st.header("Générer une publication")
|
|
@ -1,2 +1,4 @@
|
|||
streamlit
|
||||
requests
|
||||
python-dotenv
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue