Skip to content

Commit

Permalink
feat: facts api program
Browse files Browse the repository at this point in the history
  • Loading branch information
kom-senapati committed Jul 1, 2024
1 parent c88847e commit c0614b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/apps/pages/programs/ApiPrograms/fact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from requests import get
from json import loads
import streamlit as st

# code files
from src.utils.english import Speak

def play_fact():
response = get('https://uselessfacts.jsph.pl/api/v2/facts/random')
fact = loads(response.text)['text'].title()
box = st.empty()
box.markdown(fact)
Speak(fact)
5 changes: 4 additions & 1 deletion src/apps/pages/programs/apiProgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

def apiPrograms():
st.title('API Programs')
choice = st.selectbox('Select a program to execute', [None, "Jokes"])
choice = st.selectbox('Select a program to execute', [None, "Jokes", "Facts"])
st.markdown('---')
if choice == "Jokes":
from src.apps.pages.programs.ApiPrograms.joke import play_joke
play_joke()
elif choice == "Facts":
from src.apps.pages.programs.ApiPrograms.fact import play_fact
play_fact()
else:
st.info("Star this project on [GitHub](https://github.com/Avdhesh-Varshney/Jarvis), if you like it!", icon='⭐')

Expand Down

0 comments on commit c0614b2

Please sign in to comment.