thechaiexperiment commited on
Commit
9cfabcd
·
verified ·
1 Parent(s): bd5a628

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -0
app.py CHANGED
@@ -637,6 +637,64 @@ async def root():
637
  <footer>
638
  <p>&copy; 2025 AI Medical Assistance Hub | <a href="#">GitHub</a> | <a href="#">Hugging Face</a></p>
639
  </footer>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  </body>
641
  </html>
642
  """
 
637
  <footer>
638
  <p>&copy; 2025 AI Medical Assistance Hub | <a href="#">GitHub</a> | <a href="#">Hugging Face</a></p>
639
  </footer>
640
+ <script>
641
+ async function submitData() {
642
+ // Get input values
643
+ const conditions = document.getElementById('conditions').value;
644
+ const symptoms = document.getElementById('symptoms').value;
645
+ const mental_health = document.getElementById('mental_health').value;
646
+ const language = document.getElementById('language').value;
647
+ const count = document.getElementById('count').value;
648
+ const question = document.getElementById('question').value;
649
+
650
+ // Construct the profile object
651
+ const profile = {
652
+ conditions: conditions,
653
+ daily_symptoms: symptoms,
654
+ mental_health: mental_health,
655
+ language_code: language,
656
+ count: count
657
+ };
658
+
659
+ try {
660
+ // Send request to /api/chat endpoint
661
+ const chatResponse = await fetch('/api/chat', {
662
+ method: 'POST',
663
+ headers: {
664
+ 'Content-Type': 'application/json',
665
+ },
666
+ body: JSON.stringify({ query: question, language_code: language })
667
+ });
668
+ const chatData = await chatResponse.json();
669
+ document.getElementById('chat_output').textContent = chatData.response;
670
+
671
+ // Send request to /api/resources endpoint
672
+ const resourcesResponse = await fetch('/api/resources', {
673
+ method: 'POST',
674
+ headers: {
675
+ 'Content-Type': 'application/json',
676
+ },
677
+ body: JSON.stringify(profile)
678
+ });
679
+ const resourcesData = await resourcesResponse.json();
680
+ document.getElementById('resources_output').textContent = JSON.stringify(resourcesData, null, 2);
681
+
682
+ // Send request to /api/recipes endpoint
683
+ const recipesResponse = await fetch('/api/recipes', {
684
+ method: 'POST',
685
+ headers: {
686
+ 'Content-Type': 'application/json',
687
+ },
688
+ body: JSON.stringify(profile)
689
+ });
690
+ const recipesData = await recipesResponse.json();
691
+ document.getElementById('recipes_output').textContent = JSON.stringify(recipesData, null, 2);
692
+
693
+ } catch (error) {
694
+ console.error('Error submitting data:', error);
695
+ }
696
+ }
697
+ </script>
698
  </body>
699
  </html>
700
  """