Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,42 +1,45 @@
|
|
| 1 |
-
import random
|
| 2 |
import streamlit as st
|
|
|
|
| 3 |
|
| 4 |
-
# مسار الملف النصي المحلي
|
| 5 |
FILE_PATH = "ask.txt"
|
| 6 |
|
|
|
|
| 7 |
def fetch_questions_from_file():
|
| 8 |
try:
|
| 9 |
-
# قراءة الأسئلة من الملف
|
| 10 |
with open(FILE_PATH, "r", encoding="utf-8") as file:
|
| 11 |
-
questions = file.
|
| 12 |
-
return questions
|
| 13 |
except Exception as e:
|
| 14 |
-
st.error(
|
| 15 |
return []
|
| 16 |
|
|
|
|
| 17 |
def main():
|
| 18 |
-
|
| 19 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
questions = fetch_questions_from_file()
|
| 24 |
if questions:
|
| 25 |
question = random.choice(questions)
|
| 26 |
st.success(f"سؤال : {question}")
|
| 27 |
else:
|
| 28 |
-
st.
|
| 29 |
-
st.markdown(
|
| 30 |
-
"""
|
| 31 |
-
<style>
|
| 32 |
-
body {
|
| 33 |
-
background-color: #1E1E1E; /* Dark background color */
|
| 34 |
-
color: #FFFFFF; /* White text color */
|
| 35 |
-
}
|
| 36 |
-
</style>
|
| 37 |
-
""",
|
| 38 |
-
unsafe_allow_html=True)
|
| 39 |
-
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
| 42 |
main()
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import random
|
| 3 |
|
| 4 |
+
# تحديد مسار الملف النصي المحلي
|
| 5 |
FILE_PATH = "ask.txt"
|
| 6 |
|
| 7 |
+
# دالة لجلب الأسئلة من الملف النصي
|
| 8 |
def fetch_questions_from_file():
|
| 9 |
try:
|
|
|
|
| 10 |
with open(FILE_PATH, "r", encoding="utf-8") as file:
|
| 11 |
+
questions = file.readlines()
|
| 12 |
+
return [q.strip() for q in questions]
|
| 13 |
except Exception as e:
|
| 14 |
+
st.error("حدث خطأ أثناء قراءة الملف: {}".format(e))
|
| 15 |
return []
|
| 16 |
|
| 17 |
+
# تطبيق Streamlit
|
| 18 |
def main():
|
| 19 |
+
# إضافة نمط CSS لتغيير خلفية التطبيق
|
| 20 |
+
st.markdown(
|
| 21 |
+
"""
|
| 22 |
+
<style>
|
| 23 |
+
body {
|
| 24 |
+
background-color: #1E1E1E; /* لون الخلفية الأسود */
|
| 25 |
+
color: #FFFFFF; /* لون النص الأبيض */
|
| 26 |
+
}
|
| 27 |
+
</style>
|
| 28 |
+
""",
|
| 29 |
+
unsafe_allow_html=True
|
| 30 |
+
)
|
| 31 |
|
| 32 |
+
st.title("🎲 سؤال عشوائي")
|
| 33 |
+
st.write("احصل على سؤال عشوائي.")
|
| 34 |
+
|
| 35 |
+
# زر لعرض سؤال عشوائي
|
| 36 |
+
if st.button("احصل ع سؤال"):
|
| 37 |
questions = fetch_questions_from_file()
|
| 38 |
if questions:
|
| 39 |
question = random.choice(questions)
|
| 40 |
st.success(f"سؤال : {question}")
|
| 41 |
else:
|
| 42 |
+
st.error("لم يتم العثور على أسئلة.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
| 45 |
main()
|