File size: 1,069 Bytes
685a1e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()