ASK / app.py
My-AI-Projects's picture
Upload app.py
685a1e8 verified
raw
history blame
1.07 kB
import random
import streamlit as st
# مسار الملف النصي المحلي
FILE_PATH = "ask.txt"
def fetch_questions_from_file():
try:
# قراءة الأسئلة من الملف
with open(FILE_PATH, "r", encoding="utf-8") as file:
questions = file.read().splitlines() # قراءة كل سطر كسؤال
return questions
except Exception as e:
st.error(f"حدث خطأ أثناء قراءة الأسئلة: {e}")
return []
def main():
st.title("ايه الكلام ^_^ ")
st.write("اضغط على الزر للحصول على سؤال عشوائي .")
# زر للحصول على سؤال عشوائي
if st.button("احصل على سؤال عشوائي"):
questions = fetch_questions_from_file()
if questions:
question = random.choice(questions)
st.success(f"سؤال: {question}")
else:
st.warning("لم يتم العثور على أسئلة ..")
if __name__ == "__main__":
main()