Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -453,119 +453,123 @@ def html(cards, pg, total):
|
|
453 |
|
454 |
return h
|
455 |
|
|
|
456 |
# โโโโโโโโโโโโโโโโโโโโโ 7. Gradio Blocks UI โโโโโโโโโโโโโโโโโโโโโ
|
457 |
def build():
|
458 |
_init_best()
|
459 |
|
460 |
-
#
|
461 |
header_html_snippet = """
|
462 |
<style>
|
463 |
.app-header{ text-align:center; margin-bottom:24px; }
|
464 |
.badge-row{
|
465 |
-
display:inline-flex;
|
466 |
-
gap:8px;
|
467 |
margin:8px 0;
|
468 |
}
|
469 |
</style>
|
470 |
-
|
471 |
<div class="app-header">
|
472 |
<h1>๐ฎ Vibe Game Craft</h1>
|
473 |
|
474 |
<div class="badge-row">
|
475 |
-
<!-- โ Vibe-Game ๊ณต๊ฐ ๋ฐฐ์ง -->
|
476 |
<a href="https://huggingface.co/spaces/openfree/Vibe-Game" target="_blank">
|
477 |
-
<img src="https://img.shields.io/static/v1?label=huggingface&message=Vibe%20Game%20Craft&color=%23800080&labelColor=%23ffa500&logo=huggingface&logoColor=%23ffff00&style=for-the-badge" alt="HF
|
478 |
</a>
|
479 |
-
|
480 |
-
<!-- โก Game Gallery ๋ฐฐ์ง -->
|
481 |
<a href="https://huggingface.co/spaces/openfree/Game-Gallery" target="_blank">
|
482 |
-
<img src="https://img.shields.io/static/v1?label=huggingface&message=Game%20Gallery&color=%23800080&labelColor=%23ffa500&logo=huggingface&logoColor=%23ffff00&style=for-the-badge" alt="HF
|
483 |
</a>
|
484 |
-
|
485 |
-
<!-- โข Discord ๋ฐฐ์ง -->
|
486 |
<a href="https://discord.gg/openfreeai" target="_blank">
|
487 |
-
<img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%230000ff&labelColor=%23800080&logo=discord&logoColor=white&style=for-the-badge" alt="Discord
|
488 |
</a>
|
489 |
</div>
|
490 |
|
491 |
-
<p>ํ๋กฌํํธ ์
๋ ฅ๋ง์ผ๋ก ์ต์ LLM๋ค๊ณผ Agent๊ฐ ํ์
ํ์ฌ ์น ๊ธฐ๋ฐ
|
492 |
</div>
|
493 |
"""
|
494 |
|
495 |
-
#
|
496 |
-
|
497 |
-
|
498 |
-
css="""
|
499 |
-
footer{display:none !important;}
|
500 |
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
box-shadow:0 -2px 10px rgba(0,0,0,0.05) !important;
|
511 |
-
margin:0 !important;
|
512 |
-
z-index:1000 !important;
|
513 |
-
}
|
514 |
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
|
|
|
|
|
|
|
|
530 |
|
531 |
-
#
|
532 |
gr.HTML(header_html_snippet)
|
533 |
|
|
|
|
|
534 |
|
535 |
-
#
|
536 |
-
bp = gr.State(1)
|
537 |
-
out = gr.HTML()
|
538 |
-
|
539 |
-
# ํ์ด์ง ๋ค๋น๊ฒ์ด์
(๋งจ ์๋ ๊ณ ์ )
|
540 |
with gr.Row(elem_classes="button-row"):
|
541 |
b_prev = gr.Button("โ ์ด์ ", size="lg")
|
542 |
b_next = gr.Button("๋ค์ โถ", size="lg")
|
543 |
-
|
544 |
-
|
|
|
|
|
|
|
545 |
d, t = page(_load_best(), p)
|
546 |
return html(d, p, t), p
|
547 |
-
|
548 |
def prev(b):
|
549 |
b = max(1, b-1)
|
550 |
h, _ = show_best(b)
|
551 |
return h, b
|
552 |
-
|
553 |
def nxt(b):
|
554 |
maxp = (len(_load_best()) + PER_PAGE - 1) // PER_PAGE
|
555 |
b = min(maxp, b+1)
|
556 |
h, _ = show_best(b)
|
557 |
return h, b
|
558 |
-
|
559 |
-
# ์ด๋ฒคํธ
|
560 |
b_prev.click(prev, inputs=[bp], outputs=[out, bp])
|
561 |
-
b_next.click(nxt,
|
562 |
-
|
563 |
-
# ์ด๊ธฐ ๋ก๋
|
564 |
-
demo.load(show_best, outputs=[out, bp])
|
565 |
-
|
566 |
-
return demo
|
567 |
|
568 |
-
|
|
|
569 |
|
570 |
-
|
571 |
-
app.launch()
|
|
|
453 |
|
454 |
return h
|
455 |
|
456 |
+
# โโโโโโโโโโโโโโโโโโโโโ 7. Gradio Blocks UI โโโโโโโโโโโโโโโโโโโโโ
|
457 |
# โโโโโโโโโโโโโโโโโโโโโ 7. Gradio Blocks UI โโโโโโโโโโโโโโโโโโโโโ
|
458 |
def build():
|
459 |
_init_best()
|
460 |
|
461 |
+
# (1) โโ ํค๋ HTML (๋ณ๊ฒฝ ์์) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
462 |
header_html_snippet = """
|
463 |
<style>
|
464 |
.app-header{ text-align:center; margin-bottom:24px; }
|
465 |
.badge-row{
|
466 |
+
display:inline-flex;
|
467 |
+
gap:8px;
|
468 |
margin:8px 0;
|
469 |
}
|
470 |
</style>
|
471 |
+
|
472 |
<div class="app-header">
|
473 |
<h1>๐ฎ Vibe Game Craft</h1>
|
474 |
|
475 |
<div class="badge-row">
|
|
|
476 |
<a href="https://huggingface.co/spaces/openfree/Vibe-Game" target="_blank">
|
477 |
+
<img src="https://img.shields.io/static/v1?label=huggingface&message=Vibe%20Game%20Craft&color=%23800080&labelColor=%23ffa500&logo=huggingface&logoColor=%23ffff00&style=for-the-badge" alt="HF-Vibe">
|
478 |
</a>
|
|
|
|
|
479 |
<a href="https://huggingface.co/spaces/openfree/Game-Gallery" target="_blank">
|
480 |
+
<img src="https://img.shields.io/static/v1?label=huggingface&message=Game%20Gallery&color=%23800080&labelColor=%23ffa500&logo=huggingface&logoColor=%23ffff00&style=for-the-badge" alt="HF-Gallery">
|
481 |
</a>
|
|
|
|
|
482 |
<a href="https://discord.gg/openfreeai" target="_blank">
|
483 |
+
<img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%230000ff&labelColor=%23800080&logo=discord&logoColor=white&style=for-the-badge" alt="Discord">
|
484 |
</a>
|
485 |
</div>
|
486 |
|
487 |
+
<p>ํ๋กฌํํธ ์
๋ ฅ๋ง์ผ๋ก ์ต์ LLM๋ค๊ณผ Agent๊ฐ ํ์
ํ์ฌ ์น ๊ธฐ๋ฐ ๊ฒ์์ ์์ฑํ๊ณ ๋ฐฐํฌํฉ๋๋ค.</p>
|
488 |
</div>
|
489 |
"""
|
490 |
|
491 |
+
# (2) โโ ์ ์ญ CSS (ํค๋ sticky + ์คํฌ๋กค ์์ญ ์ฌ์กฐ์ ) โโโโโโโโโ
|
492 |
+
css_global = """
|
493 |
+
footer{display:none !important;}
|
|
|
|
|
494 |
|
495 |
+
/* ์๋จ ํค๋๋ฅผ ํญ์ ๋ณด์ด๋๋ก ๊ณ ์ */
|
496 |
+
.app-header{
|
497 |
+
position:sticky;
|
498 |
+
top:0;
|
499 |
+
background:#fff;
|
500 |
+
z-index:1100;
|
501 |
+
padding:16px 0 8px;
|
502 |
+
border-bottom:1px solid #eee;
|
503 |
+
}
|
|
|
|
|
|
|
|
|
504 |
|
505 |
+
/* ํ๋จ ๊ณ ์ ๋ฒํผ ๋ฐ */
|
506 |
+
.button-row{
|
507 |
+
position:fixed !important;
|
508 |
+
bottom:0 !important;
|
509 |
+
left:0 !important;
|
510 |
+
right:0 !important;
|
511 |
+
height:60px !important;
|
512 |
+
background:#f0f0f0 !important;
|
513 |
+
padding:10px !important;
|
514 |
+
text-align:center !important;
|
515 |
+
box-shadow:0 -2px 10px rgba(0,0,0,0.05) !important;
|
516 |
+
margin:0 !important;
|
517 |
+
z-index:1000 !important;
|
518 |
+
}
|
519 |
+
.button-row button{
|
520 |
+
margin:0 10px !important;
|
521 |
+
padding:10px 20px !important;
|
522 |
+
font-size:16px !important;
|
523 |
+
font-weight:bold !important;
|
524 |
+
border-radius:50px !important;
|
525 |
+
}
|
526 |
|
527 |
+
/* ์นด๋ ๊ทธ๋ฆฌ๋ ์คํฌ๋กค ์์ญ */
|
528 |
+
#content-area{
|
529 |
+
overflow-y:auto !important;
|
530 |
+
height:calc(100vh - 60px - 160px) !important; /* ์ ์ฒด-๋์ด - ํ๋จ๋ฐ - ํค๋ */
|
531 |
+
box-sizing:border-box;
|
532 |
+
padding-top:10px;
|
533 |
+
}
|
534 |
+
"""
|
535 |
+
|
536 |
+
# (3) โโ Gradio Blocks โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
537 |
+
with gr.Blocks(title="Vibe Game Craft", css=css_global) as demo:
|
538 |
|
539 |
+
# โ ๊ณ ์ ํค๋
|
540 |
gr.HTML(header_html_snippet)
|
541 |
|
542 |
+
# โก ๋ณธ๋ฌธ(์นด๋ ๊ทธ๋ฆฌ๋) โ ๊ณ ์ ID ๋ถ์ฌ
|
543 |
+
out = gr.HTML(elem_id="content-area")
|
544 |
|
545 |
+
# โข ํ๋จ ํ์ด์ง ๋ค๋น๊ฒ์ด์
๋ฐ
|
|
|
|
|
|
|
|
|
546 |
with gr.Row(elem_classes="button-row"):
|
547 |
b_prev = gr.Button("โ ์ด์ ", size="lg")
|
548 |
b_next = gr.Button("๋ค์ โถ", size="lg")
|
549 |
+
|
550 |
+
# โโ ์ํ ๋ฐ ํฌํผ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
551 |
+
bp = gr.State(1)
|
552 |
+
|
553 |
+
def show_best(p=1):
|
554 |
d, t = page(_load_best(), p)
|
555 |
return html(d, p, t), p
|
556 |
+
|
557 |
def prev(b):
|
558 |
b = max(1, b-1)
|
559 |
h, _ = show_best(b)
|
560 |
return h, b
|
561 |
+
|
562 |
def nxt(b):
|
563 |
maxp = (len(_load_best()) + PER_PAGE - 1) // PER_PAGE
|
564 |
b = min(maxp, b+1)
|
565 |
h, _ = show_best(b)
|
566 |
return h, b
|
567 |
+
|
568 |
+
# โโ ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
569 |
b_prev.click(prev, inputs=[bp], outputs=[out, bp])
|
570 |
+
b_next.click(nxt, inputs=[bp], outputs=[out, bp])
|
|
|
|
|
|
|
|
|
|
|
571 |
|
572 |
+
# ์ต์ด ๋ก๋
|
573 |
+
demo.load(show_best, outputs=[out, bp])
|
574 |
|
575 |
+
return demo
|
|