import streamlit as st import random # تحديد مسار الملف النصي المحلي FILE_PATH = "ask.txt" # دالة لجلب الأسئلة من الملف النصي def fetch_questions_from_file(): try: with open(FILE_PATH, "r", encoding="utf-8") as file: questions = file.readlines() return [q.strip() for q in questions] except Exception as e: st.error("حدث خطأ أثناء قراءة الملف: {}".format(e)) return [] # تطبيق Streamlit def main(): # إضافة نمط CSS لتغيير خلفية التطبيق st.markdown( """ """, unsafe_allow_html=True ) st.title("🎲 سؤال عشوائي") st.write("احصل على سؤال عشوائي.") # زر لعرض سؤال عشوائي if st.button("احصل ع سؤال"): questions = fetch_questions_from_file() if questions: question = random.choice(questions) st.success(f"سؤال : {question}") else: st.error("لم يتم العثور على أسئلة.") if __name__ == "__main__": main()