My-AI-Projects commited on
Commit
685a1e8
·
verified ·
1 Parent(s): 4055c7f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.read().splitlines() # قراءة كل سطر كسؤال
12
+ return questions
13
+ except Exception as e:
14
+ st.error(f"حدث خطأ أثناء قراءة الأسئلة: {e}")
15
+ return []
16
+
17
+ def main():
18
+ st.title("ايه الكلام ^_^ ")
19
+ st.write("اضغط على الزر للحصول على سؤال عشوائي .")
20
+
21
+ # زر للحصول على سؤال عشوائي
22
+ if st.button("احصل على سؤال عشوائي"):
23
+ questions = fetch_questions_from_file()
24
+ if questions:
25
+ question = random.choice(questions)
26
+ st.success(f"سؤال: {question}")
27
+ else:
28
+ st.warning("لم يتم العثور على أسئلة ..")
29
+
30
+ if __name__ == "__main__":
31
+ main()