point-median-frontend/main.py

35 lines
1.1 KiB
Python
Raw Permalink Normal View History

import streamlit as st
import requests
from config import settings
import streamlit.components.v1 as components
def correct_text(text):
url = f"{settings.BACKEND_URL}/corriger"
2024-02-19 00:17:44 +00:00
response = requests.post(url, json={"text": text})
if response.status_code != 200:
st.error("Erreur lors de la requête au serveur: {response.status_code}")
return ""
else:
return response.json()["text"]
def main():
st.title("Application Point Médian")
with open("ressources/header.md", "r") as f:
st.markdown(f.read(), unsafe_allow_html=False)
2023-09-14 21:14:47 +00:00
text = st.text_area("Entre le texte à corriger", placeholder="Écris ton texte ici", height=200)
if st.button("Corriger"):
corrected_text = correct_text(text)
st.text_area("Texte corrigé:", value=corrected_text, height=200)
with open("ressources/formulaire_courriel.html", "r") as f:
components.html(f.read(), height=350, scrolling=True)
with open("ressources/footer.md", "r") as f:
st.markdown(f.read(), unsafe_allow_html=False)
if __name__ == "__main__":
main()