Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -248,58 +248,143 @@ async def try_openai_api(openai_messages):
|
|
248 |
# ------------------------
|
249 |
|
250 |
def load_json_data():
|
251 |
-
data_list = [
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
#
|
257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
return data_list
|
259 |
|
260 |
def create_template_html(title, items):
|
261 |
import html as html_lib
|
262 |
html_content = r"""
|
263 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
.prompt-grid {
|
265 |
display: grid;
|
266 |
-
grid-template-columns: repeat(auto-
|
267 |
gap: 16px;
|
268 |
padding: 12px;
|
269 |
}
|
270 |
.prompt-card {
|
271 |
background: white;
|
272 |
-
border: 1px solid #
|
273 |
border-radius: 12px;
|
274 |
-
padding:
|
275 |
cursor: pointer;
|
276 |
-
box-shadow: 0 4px
|
277 |
transition: all 0.3s ease;
|
|
|
|
|
|
|
278 |
}
|
279 |
.prompt-card:hover {
|
280 |
transform: translateY(-4px);
|
281 |
-
box-shadow: 0
|
|
|
282 |
}
|
283 |
.card-name {
|
284 |
-
font-weight:
|
285 |
-
margin-bottom:
|
286 |
-
font-size:
|
287 |
-
color: #
|
|
|
|
|
|
|
|
|
288 |
}
|
289 |
.card-prompt {
|
290 |
-
font-size:
|
291 |
-
line-height: 1.
|
292 |
-
color: #
|
293 |
display: -webkit-box;
|
294 |
-
-webkit-line-clamp:
|
295 |
-webkit-box-orient: vertical;
|
296 |
overflow: hidden;
|
297 |
-
|
298 |
-
background-color: #f8f9fa;
|
299 |
-
padding: 8px;
|
300 |
-
border-radius: 6px;
|
301 |
}
|
302 |
</style>
|
|
|
303 |
<div class="prompt-grid">
|
304 |
"""
|
305 |
for item in items:
|
|
|
248 |
# ------------------------
|
249 |
|
250 |
def load_json_data():
|
251 |
+
data_list = []
|
252 |
+
for i, demo in enumerate(DEMO_LIST):
|
253 |
+
game_type = ""
|
254 |
+
desc = demo["description"]
|
255 |
+
|
256 |
+
# 게임 타입 추정
|
257 |
+
if "테트리스" in desc or "블록" in desc:
|
258 |
+
game_type = "[퍼즐] 테트리스"
|
259 |
+
elif "체스" in desc:
|
260 |
+
game_type = "[보드] 체스"
|
261 |
+
elif "메모리 카드" in desc or "짝을 맞추는" in desc:
|
262 |
+
game_type = "[카드] 메모리 게임"
|
263 |
+
elif "슈팅" in desc or "우주선" in desc:
|
264 |
+
game_type = "[액션] 슈팅 게임"
|
265 |
+
elif "슬라이드 퍼즐" in desc:
|
266 |
+
game_type = "[퍼즐] 슬라이드 퍼즐"
|
267 |
+
elif "뱀 게임" in desc:
|
268 |
+
game_type = "[아케이드] 스네이크"
|
269 |
+
elif "브레이크아웃" in desc or "벽돌" in desc:
|
270 |
+
game_type = "[아케이드] 브레이크아웃"
|
271 |
+
elif "타워 디펜스" in desc:
|
272 |
+
game_type = "[전략] 타워 디펜스"
|
273 |
+
elif "엔드리스 러너" in desc or "달리며 장애물" in desc:
|
274 |
+
game_type = "[액션] 러너 게임"
|
275 |
+
elif "플랫포머" in desc:
|
276 |
+
game_type = "[액션] 플랫포머"
|
277 |
+
elif "미로" in desc:
|
278 |
+
game_type = "[퍼즐] 미로 게임"
|
279 |
+
elif "RPG" in desc or "턴제" in desc:
|
280 |
+
game_type = "[RPG] 턴제 전투"
|
281 |
+
elif "매치-3" in desc or "같은 색상" in desc:
|
282 |
+
game_type = "[퍼즐] 매치3 게임"
|
283 |
+
elif "플래피 버드" in desc:
|
284 |
+
game_type = "[아케이드] 플래피 버드"
|
285 |
+
elif "차이점" in desc:
|
286 |
+
game_type = "[퍼즐] 차이 찾기"
|
287 |
+
elif "타이핑" in desc:
|
288 |
+
game_type = "[교육] 타이핑 게임"
|
289 |
+
elif "골프" in desc:
|
290 |
+
game_type = "[스포츠] 미니 골프"
|
291 |
+
elif "낚시" in desc:
|
292 |
+
game_type = "[시뮬레이션] 낚시"
|
293 |
+
elif "빙고" in desc:
|
294 |
+
game_type = "[보드] 빙고"
|
295 |
+
elif "리듬" in desc:
|
296 |
+
game_type = "[음악] 리듬 게임"
|
297 |
+
elif "레이싱" in desc:
|
298 |
+
game_type = "[레이싱] 탑다운 드라이빙"
|
299 |
+
elif "퀴즈" in desc:
|
300 |
+
game_type = "[교육] 퀴즈"
|
301 |
+
elif "사격" in desc:
|
302 |
+
game_type = "[아케이드] 사격 갤러리"
|
303 |
+
elif "보드 게임" in desc or "주사위" in desc:
|
304 |
+
game_type = "[보드] 룰렛 게임"
|
305 |
+
elif "좀비" in desc and "서바이벌" in desc:
|
306 |
+
game_type = "[액션] 좀비 서바이벌"
|
307 |
+
elif "페널티킥" in desc or "축구" in desc:
|
308 |
+
game_type = "[스포츠] 페널티킥"
|
309 |
+
elif "지뢰찾기" in desc:
|
310 |
+
game_type = "[퍼즐] 지뢰찾기"
|
311 |
+
elif "Connect Four" in desc:
|
312 |
+
game_type = "[보드] 사목게임"
|
313 |
+
elif "스크래블" in desc or "단어" in desc:
|
314 |
+
game_type = "[보드] 단어 게임"
|
315 |
+
elif "탱크" in desc:
|
316 |
+
game_type = "[액션] 탱크 배틀"
|
317 |
+
elif "보석" in desc:
|
318 |
+
game_type = "[퍼즐] 보석 매치"
|
319 |
+
else:
|
320 |
+
game_type = f"[게임] 예제 {i+1}"
|
321 |
+
|
322 |
+
# 설명 요약 (너무 길면 축약)
|
323 |
+
short_desc = desc[:150] + "..." if len(desc) > 150 else desc
|
324 |
+
|
325 |
+
data_list.append({
|
326 |
+
"name": game_type,
|
327 |
+
"prompt": desc
|
328 |
+
})
|
329 |
+
|
330 |
return data_list
|
331 |
|
332 |
def create_template_html(title, items):
|
333 |
import html as html_lib
|
334 |
html_content = r"""
|
335 |
<style>
|
336 |
+
.template-title {
|
337 |
+
font-size: 1.1rem;
|
338 |
+
font-weight: 600;
|
339 |
+
margin-bottom: 16px;
|
340 |
+
color: #0066cc;
|
341 |
+
text-align: center;
|
342 |
+
}
|
343 |
.prompt-grid {
|
344 |
display: grid;
|
345 |
+
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
346 |
gap: 16px;
|
347 |
padding: 12px;
|
348 |
}
|
349 |
.prompt-card {
|
350 |
background: white;
|
351 |
+
border: 1px solid #e9ecef;
|
352 |
border-radius: 12px;
|
353 |
+
padding: 15px;
|
354 |
cursor: pointer;
|
355 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
356 |
transition: all 0.3s ease;
|
357 |
+
height: 180px;
|
358 |
+
display: flex;
|
359 |
+
flex-direction: column;
|
360 |
}
|
361 |
.prompt-card:hover {
|
362 |
transform: translateY(-4px);
|
363 |
+
box-shadow: 0 8px 15px rgba(0,0,0,0.1);
|
364 |
+
border-color: #66a3ff;
|
365 |
}
|
366 |
.card-name {
|
367 |
+
font-weight: 600;
|
368 |
+
margin-bottom: 10px;
|
369 |
+
font-size: 14px;
|
370 |
+
color: #2c3e50;
|
371 |
+
padding: 5px 10px;
|
372 |
+
background: #f7f9fc;
|
373 |
+
border-radius: 6px;
|
374 |
+
display: inline-block;
|
375 |
}
|
376 |
.card-prompt {
|
377 |
+
font-size: 12px;
|
378 |
+
line-height: 1.5;
|
379 |
+
color: #546e7a;
|
380 |
display: -webkit-box;
|
381 |
+
-webkit-line-clamp: 6;
|
382 |
-webkit-box-orient: vertical;
|
383 |
overflow: hidden;
|
384 |
+
flex-grow: 1;
|
|
|
|
|
|
|
385 |
}
|
386 |
</style>
|
387 |
+
<div class="template-title">🎮 다양한 게임 템플릿을 선택해 보세요</div>
|
388 |
<div class="prompt-grid">
|
389 |
"""
|
390 |
for item in items:
|