ASK / app.py
My-AI-Projects's picture
Update app.py
8c5ec32 verified
raw
history blame
1.03 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()