File size: 1,246 Bytes
8c5ec32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b513630
 
 
 
 
 
 
 
 
 
 
8c5ec32
 
 
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
33
34
35
36
37
38
39
40
41
42
43
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("لم يتم العثور على أسئلة ..")
    st.markdown(
    """
    <style>
    body {
        background-color: #1E1E1E;  /* Dark background color */
        color: #FFFFFF;  /* White text color */
    }
    </style>
    """,
    unsafe_allow_html=True)


if __name__ == "__main__":
    main()