Rathapoom commited on
Commit
35700e5
·
verified ·
1 Parent(s): 912046e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +269 -0
app.py CHANGED
@@ -13,6 +13,275 @@ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
13
  from datetime import datetime
14
  import random
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Set up logging
17
  logging.basicConfig(
18
  level=logging.INFO,
 
13
  from datetime import datetime
14
  import random
15
 
16
+ # === 2. CONFIGURATIONS ===
17
+ # Theme Configuration
18
+ story_themes = {
19
+ 'fantasy': {
20
+ 'id': 'fantasy',
21
+ 'icon': '🏰',
22
+ 'name_en': 'Fantasy & Magic',
23
+ 'name_th': 'แฟนตาซีและเวทมนตร์',
24
+ 'description_th': 'ผจญภัยในโลกแห่งเวทมนตร์และจินตนาการ',
25
+ 'description_en': 'Adventure in a world of magic and imagination',
26
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
27
+ 'vocabulary': {
28
+ 'Beginner': ['dragon', 'magic', 'wand', 'spell', 'wizard', 'fairy', 'castle', 'king', 'queen'],
29
+ 'Intermediate': ['potion', 'enchanted', 'castle', 'creature', 'power', 'scroll', 'portal', 'magical'],
30
+ 'Advanced': ['sorcery', 'mystical', 'enchantment', 'prophecy', 'ancient', 'legendary', 'mythical']
31
+ },
32
+ 'story_starters': {
33
+ 'Beginner': [
34
+ {'th': 'วันหนึ่งฉันเจอไม้วิเศษในสวน...', 'en': 'One day, I found a magic wand in the garden...'},
35
+ {'th': 'มังกรน้อยกำลังมองหาเพื่อน...', 'en': 'The little dragon was looking for a friend...'},
36
+ {'th': 'เจ้าหญิงน้อยมีความลับวิเศษ...', 'en': 'The little princess had a magical secret...'}
37
+ ],
38
+ 'Intermediate': [
39
+ {'th': 'ในปราสาทเก่าแก่มีประตูลึกลับ...', 'en': 'In the ancient castle, there was a mysterious door...'},
40
+ {'th': 'เมื่อน้ำยาวิเศษเริ่มส่องแสง...', 'en': 'When the magic potion started to glow...'},
41
+ {'th': 'หนังสือเวทมนตร์เล่มนั้นเปิดออกเอง...', 'en': 'The spellbook opened by itself...'}
42
+ ],
43
+ 'Advanced': [
44
+ {'th': 'คำทำนายโบราณกล่าวถึงผู้วิเศษที่จะมา...', 'en': 'The ancient prophecy spoke of a wizard who would come...'},
45
+ {'th': 'ในโลกที่เวทมนตร์กำลังจะสูญหาย...', 'en': 'In a world where magic was fading away...'},
46
+ {'th': 'ณ จุดบรรจบของดวงดาวทั้งห้า...', 'en': 'At the convergence of the five stars...'}
47
+ ]
48
+ },
49
+ 'background_color': '#E8F3FF',
50
+ 'accent_color': '#1E88E5'
51
+ },
52
+ 'nature': {
53
+ 'id': 'nature',
54
+ 'icon': '🌳',
55
+ 'name_en': 'Nature & Animals',
56
+ 'name_th': 'ธรรมชาติและสัตว์โลก',
57
+ 'description_th': 'เรื่องราวของสัตว์น้อยใหญ่และธรรมชาติอันงดงาม',
58
+ 'description_en': 'Stories of animals and beautiful nature',
59
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
60
+ 'vocabulary': {
61
+ 'Beginner': ['tree', 'bird', 'flower', 'cat', 'dog', 'garden', 'rabbit', 'butterfly', 'sun'],
62
+ 'Intermediate': ['forest', 'river', 'mountain', 'wildlife', 'season', 'weather', 'rainbow', 'stream'],
63
+ 'Advanced': ['ecosystem', 'habitat', 'wilderness', 'environment', 'conservation', 'migration', 'climate']
64
+ },
65
+ 'story_starters': {
66
+ 'Beginner': [
67
+ {'th': 'แมวน้อยเจอนกในสวน...', 'en': 'The little cat found a bird in the garden...'},
68
+ {'th': 'ดอกไม้สวยกำลังเบ่งบาน...', 'en': 'The beautiful flower was blooming...'},
69
+ {'th': 'กระต่ายน้อยหลงทางในสวน...', 'en': 'The little rabbit got lost in the garden...'}
70
+ ],
71
+ 'Intermediate': [
72
+ {'th': 'ในป่าใหญ่มีเสียงลึกลับ...', 'en': 'In the big forest, there was a mysterious sound...'},
73
+ {'th': 'แม่น้ำสายนี้มีความลับ...', 'en': 'This river had a secret...'},
74
+ {'th': 'สายรุ้งพาดผ่านภูเขา...', 'en': 'A rainbow stretched across the mountain...'}
75
+ ],
76
+ 'Advanced': [
77
+ {'th': 'ฝูงนกกำลังอพยพย้ายถิ่น...', 'en': 'The birds were migrating...'},
78
+ {'th': 'ป่าฝนกำลังเปลี่ยนแปลง...', 'en': 'The rainforest was changing...'},
79
+ {'th': 'ความลับของระบบนิเวศ...', 'en': 'The secret of the ecosystem...'}
80
+ ]
81
+ },
82
+ 'background_color': '#F1F8E9',
83
+ 'accent_color': '#4CAF50'
84
+ },
85
+ 'space': {
86
+ 'id': 'space',
87
+ 'icon': '🚀',
88
+ 'name_en': 'Space Adventure',
89
+ 'name_th': 'ผจญภัยในอวกาศ',
90
+ 'description_th': 'เรื่องราวการสำรวจอวกาศและดวงดาวอันน่าตื่นเต้น',
91
+ 'description_en': 'Exciting stories of space exploration and celestial discoveries',
92
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
93
+ 'vocabulary': {
94
+ 'Beginner': ['star', 'moon', 'planet', 'sun', 'rocket', 'alien', 'space', 'light'],
95
+ 'Intermediate': ['astronaut', 'spacecraft', 'galaxy', 'meteor', 'satellite', 'orbit', 'comet'],
96
+ 'Advanced': ['constellation', 'nebula', 'astronomy', 'telescope', 'exploration', 'discovery']
97
+ },
98
+ 'story_starters': {
99
+ 'Beginner': [
100
+ {'th': 'จรวดลำน้อยพร้อมบินแล้ว...', 'en': 'The little rocket was ready to fly...'},
101
+ {'th': 'ดาวดวงน้อยเปล่งแสงวิบวับ...', 'en': 'The little star twinkled brightly...'},
102
+ {'th': 'มนุษย์ต่างดาวที่เป็นมิตร...', 'en': 'The friendly alien...'}
103
+ ],
104
+ 'Intermediate': [
105
+ {'th': 'นักบินอวกาศพบสิ่งประหลาด...', 'en': 'The astronaut found something strange...'},
106
+ {'th': 'ดาวเคราะห์ดวงใหม่ถูกค้นพบ...', 'en': 'A new planet was discovered...'},
107
+ {'th': 'สถานีอวกาศส่งสัญญาณลึกลับ...', 'en': 'The space station sent a mysterious signal...'}
108
+ ],
109
+ 'Advanced': [
110
+ {'th': 'การสำรวจดาวหางนำไปสู่การค้นพบ...', 'en': 'The comet exploration led to a discovery...'},
111
+ {'th': 'กาแล็กซี่ที่ไม่มีใครเคยเห็น...', 'en': 'An unknown galaxy appeared...'},
112
+ {'th': 'ความลับของหลุมดำ...', 'en': 'The secret of the black hole...'}
113
+ ]
114
+ },
115
+ 'background_color': '#E1F5FE',
116
+ 'accent_color': '#0288D1'
117
+ },
118
+ 'adventure': {
119
+ 'id': 'adventure',
120
+ 'icon': '🗺️',
121
+ 'name_en': 'Adventure & Quest',
122
+ 'name_th': 'การผจญภัยและการค้นหา',
123
+ 'description_th': 'ออกผจญภัยค้นหาสมบัติและความลับต่างๆ',
124
+ 'description_en': 'Embark on quests to find treasures and secrets',
125
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
126
+ 'vocabulary': {
127
+ 'Beginner': ['map', 'treasure', 'cave', 'island', 'path', 'boat', 'key', 'chest'],
128
+ 'Intermediate': ['compass', 'adventure', 'journey', 'mystery', 'explore', 'discover', 'quest'],
129
+ 'Advanced': ['expedition', 'archaeology', 'artifact', 'ancient', 'mysterious', 'discovery']
130
+ },
131
+ 'story_starters': {
132
+ 'Beginner': [
133
+ {'th': 'แผนที่เก่าแก่ชิ้นหนึ่ง...', 'en': 'An old map showed...'},
134
+ {'th': 'บนเกาะเล็กๆ มีสมบัติ...', 'en': 'On a small island, there was a treasure...'},
135
+ {'th': 'ถ้ำลึกลับถูกค้นพบ...', 'en': 'A mysterious cave was found...'}
136
+ ],
137
+ 'Intermediate': [
138
+ {'th': 'เข็มทิศวิเศษชี้ไปที่...', 'en': 'The magical compass pointed to...'},
139
+ {'th': 'การเดินทางเริ่มต้นที่...', 'en': 'The journey began at...'},
140
+ {'th': 'ความลับของวัตถุโบราณ...', 'en': 'The secret of the ancient artifact...'}
141
+ ],
142
+ 'Advanced': [
143
+ {'th': 'การสำรวจซากปรักหักพังนำไปสู่...', 'en': 'The ruins exploration led to...'},
144
+ {'th': 'นักโบราณคดีค้นพบ...', 'en': 'The archaeologist discovered...'},
145
+ {'th': 'ความลับของอารยธรรมโบราณ...', 'en': 'The secret of the ancient civilization...'}
146
+ ]
147
+ },
148
+ 'background_color': '#FFF3E0',
149
+ 'accent_color': '#FF9800'
150
+ },
151
+ 'school': {
152
+ 'id': 'school',
153
+ 'icon': '🏫',
154
+ 'name_en': 'School & Friends',
155
+ 'name_th': 'โรงเรียนและเพื่อน',
156
+ 'description_th': 'เรื่องราวสนุกๆ ในโรงเรียนกับเพื่อนๆ',
157
+ 'description_en': 'Fun stories about school life and friendship',
158
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
159
+ 'vocabulary': {
160
+ 'Beginner': ['friend', 'teacher', 'book', 'classroom', 'pencil', 'desk', 'lunch', 'play'],
161
+ 'Intermediate': ['homework', 'project', 'library', 'playground', 'student', 'lesson', 'study'],
162
+ 'Advanced': ['presentation', 'experiment', 'knowledge', 'research', 'collaboration', 'achievement']
163
+ },
164
+ 'story_starters': {
165
+ 'Beginner': [
166
+ {'th': 'วันแรกในห้องเรียนใหม่...', 'en': 'First day in the new classroom...'},
167
+ {'th': 'เพื่อนใหม่ในโรงเรียน...', 'en': 'A new friend at school...'},
168
+ {'th': 'ที่โต๊ะอาหารกลางวัน...', 'en': 'At the lunch table...'}
169
+ ],
170
+ 'Intermediate': [
171
+ {'th': 'โครงงานพิเศษของห้องเรา...', 'en': 'Our class special project...'},
172
+ {'th': 'ในห้องสมุดมีความลับ...', 'en': 'The library had a secret...'},
173
+ {'th': 'การทดลองวิทยาศาสตร์ครั้งนี้...', 'en': 'This science experiment...'}
174
+ ],
175
+ 'Advanced': [
176
+ {'th': 'การนำเสนอครั้งสำคัญ...', 'en': 'The important presentation...'},
177
+ {'th': 'การค้นคว้าพิเศษนำไปสู่...', 'en': 'The special research led to...'},
178
+ {'th': 'โครงการความร่วมมือระหว่างห้อง...', 'en': 'The inter-class collaboration project...'}
179
+ ]
180
+ },
181
+ 'background_color': '#F3E5F5',
182
+ 'accent_color': '#9C27B0'
183
+ },
184
+ 'superhero': {
185
+ 'id': 'superhero',
186
+ 'icon': '🦸',
187
+ 'name_en': 'Superheroes',
188
+ 'name_th': 'ซูเปอร์ฮีโร่',
189
+ 'description_th': 'เรื่องราวของฮีโร่ตัวน้อยผู้ช่วยเหลือผู้อื่น',
190
+ 'description_en': 'Stories of young heroes helping others',
191
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
192
+ 'vocabulary': {
193
+ 'Beginner': ['hero', 'help', 'save', 'power', 'mask', 'cape', 'fly', 'strong'],
194
+ 'Intermediate': ['rescue', 'protect', 'brave', 'courage', 'mission', 'team', 'secret', 'mighty'],
195
+ 'Advanced': ['superhero', 'extraordinary', 'responsibility', 'leadership', 'determination', 'justice']
196
+ },
197
+ 'story_starters': {
198
+ 'Beginner': [
199
+ {'th': 'ฮีโร่น้อยคนใหม่ของเมือง...', 'en': 'The city\'s new young hero...'},
200
+ {'th': 'พลังพิเศษของฉันทำให้...', 'en': 'My special power made me...'},
201
+ {'th': 'เมื่อต้องช่วยเหลือแมวตัวน้อย...', 'en': 'When I had to save a little cat...'}
202
+ ],
203
+ 'Intermediate': [
204
+ {'th': 'ภารกิจลับของทีมฮีโร่...', 'en': 'The hero team\'s secret mission...'},
205
+ {'th': 'พลังใหม่ที่น่าประหลาดใจ...', 'en': 'A surprising new power...'},
206
+ {'th': 'การช่วยเหลือครั้งสำคัญ...', 'en': 'An important rescue mission...'}
207
+ ],
208
+ 'Advanced': [
209
+ {'th': 'ความรับผิดชอบของการเป็นฮีโร่...', 'en': 'The responsibility of being a hero...'},
210
+ {'th': 'เมื่อเมืองต้องการฮีโร่...', 'en': 'When the city needed a hero...'},
211
+ {'th': 'การต่อสู้เพื่อความยุติธรรม...', 'en': 'Fighting for justice...'}
212
+ ]
213
+ },
214
+ 'background_color': '#FFE0B2',
215
+ 'accent_color': '#F57C00'
216
+ },
217
+ 'mystery': {
218
+ 'id': 'mystery',
219
+ 'icon': '🔍',
220
+ 'name_en': 'Mystery & Detective',
221
+ 'name_th': 'ไขปริศนาและนักสืบ',
222
+ 'description_th': 'สืบสวนปริศนาและไขความลับต่างๆ',
223
+ 'description_en': 'Solve mysteries and uncover secrets',
224
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
225
+ 'vocabulary': {
226
+ 'Beginner': ['clue', 'find', 'look', 'search', 'mystery', 'hidden', 'secret', 'detective'],
227
+ 'Intermediate': ['investigate', 'evidence', 'puzzle', 'solve', 'discover', 'suspicious', 'case'],
228
+ 'Advanced': ['investigation', 'deduction', 'enigma', 'cryptic', 'mysterious', 'revelation']
229
+ },
230
+ 'story_starters': {
231
+ 'Beginner': [
232
+ {'th': 'มีรอยปริศนาในสวน...', 'en': 'There were mysterious footprints in the garden...'},
233
+ {'th': 'จดหมายลึกลับถูกส่งมา...', 'en': 'A mysterious letter arrived...'},
234
+ {'th': 'ของเล่นหายไปอย่างลึกลับ...', 'en': 'The toy mysteriously disappeared...'}
235
+ ],
236
+ 'Intermediate': [
237
+ {'th': 'เบาะแสชิ้นแรกนำไปสู่...', 'en': 'The first clue led to...'},
238
+ {'th': 'ความลับในห้องเก่า...', 'en': 'The secret in the old room...'},
239
+ {'th': 'รหัสลับถูกค้นพบ...', 'en': 'A secret code was found...'}
240
+ ],
241
+ 'Advanced': [
242
+ {'th': 'คดีปริศนาที่ยากที่สุด...', 'en': 'The most challenging mystery case...'},
243
+ {'th': 'ความลับที่ซ่อนอยู่มานาน...', 'en': 'A long-hidden secret...'},
244
+ {'th': 'การสืบสวนนำไปสู่การค้นพบ...', 'en': 'The investigation led to a discovery...'}
245
+ ]
246
+ },
247
+ 'background_color': '#E0E0E0',
248
+ 'accent_color': '#616161'
249
+ },
250
+ 'science': {
251
+ 'id': 'science',
252
+ 'icon': '🔬',
253
+ 'name_en': 'Science & Discovery',
254
+ 'name_th': 'วิทยาศาสตร์และการค้นพบ',
255
+ 'description_th': 'การทดลองและค้นพบทางวิทยาศาสตร์ที่น่าตื่นเต้น',
256
+ 'description_en': 'Exciting scientific experiments and discoveries',
257
+ 'level_range': ['Beginner', 'Intermediate', 'Advanced'],
258
+ 'vocabulary': {
259
+ 'Beginner': ['experiment', 'science', 'lab', 'test', 'mix', 'observe', 'change', 'result'],
260
+ 'Intermediate': ['hypothesis', 'research', 'discovery', 'invention', 'laboratory', 'scientist'],
261
+ 'Advanced': ['innovation', 'technological', 'breakthrough', 'analysis', 'investigation']
262
+ },
263
+ 'story_starters': {
264
+ 'Beginner': [
265
+ {'th': 'การทดลองง่ายๆ เริ่มต้นด้วย...', 'en': 'The simple experiment started with...'},
266
+ {'th': 'ในห้องทดลองมีสิ่งมหัศจรรย์...', 'en': 'In the lab, there was something amazing...'},
267
+ {'th': 'เมื่อผสมสองสิ่งเข้าด้วยกัน...', 'en': 'When mixing the two things together...'}
268
+ ],
269
+ 'Intermediate': [
270
+ {'th': 'การค้นพบที่น่าประหลาดใจ...', 'en': 'A surprising discovery...'},
271
+ {'th': 'สิ่งประดิษฐ์ใหม่ทำให้...', 'en': 'The new invention made...'},
272
+ {'th': 'การทดลองที่ไม่คาดคิด...', 'en': 'An unexpected experiment...'}
273
+ ],
274
+ 'Advanced': [
275
+ {'th': 'นวัตกรรมที่จะเปลี่ยนโลก...', 'en': 'Innovation that would change the world...'},
276
+ {'th': 'การค้นพบทางวิทยาศาสตร์ครั้งสำคัญ...', 'en': 'An important scientific discovery...'},
277
+ {'th': 'เทคโนโลยีใหม่ที่น่าทึ่ง...', 'en': 'Amazing new technology...'}
278
+ ]
279
+ },
280
+ 'background_color': '#E8EAF6',
281
+ 'accent_color': '#3F51B5'
282
+ }
283
+ }
284
+
285
  # Set up logging
286
  logging.basicConfig(
287
  level=logging.INFO,