openfree commited on
Commit
fee886c
ยท
verified ยท
1 Parent(s): c8e0eb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -66
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
- # --- 1) ํ—ค๋”์šฉ HTML ์ •์˜ ---------------------------------
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 Vibe badge">
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 Gallery badge">
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 badge">
488
  </a>
489
  </div>
490
 
491
- <p>ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ๋งŒ์œผ๋กœ ์ตœ์‹  LLM๋“ค๊ณผ Agent๊ฐ€ ํ˜‘์—…ํ•˜์—ฌ ์›น ๊ธฐ๋ฐ˜ HTML5, JavaScript, CSS ๊ฒŒ์ž„์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์‹ค์‹œ๊ฐ„ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์™€ ๋ฐฐํฌ ๊ธฐ๋Šฅ๋„ ์ง€์›๋ฉ๋‹ˆ๋‹ค.</p>
492
  </div>
493
  """
494
 
495
- # --- 2) Gradio Blocks ์‹œ์ž‘ --------------------------------
496
- with gr.Blocks(
497
- title="Vibe Game Craft",
498
- css="""
499
- footer{display:none !important;}
500
 
501
- .button-row{
502
- position:fixed !important;
503
- bottom:0 !important;
504
- left:0 !important;
505
- right:0 !important;
506
- height:60px !important;
507
- background:#f0f0f0 !important;
508
- padding:10px !important;
509
- text-align:center !important;
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
- .button-row button{
516
- margin:0 10px !important;
517
- padding:10px 20px !important;
518
- font-size:16px !important;
519
- font-weight:bold !important;
520
- border-radius:50px !important;
521
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
 
523
- /* Allow scrolling in the HTML component */
524
- #component-0{
525
- overflow-y:auto !important;
526
- height:calc(100vh - 60px) !important;
527
- }
528
- """
529
- ) as demo:
 
 
 
 
530
 
531
- # (1) โœจ ํ—ค๋”๋ฅผ ๊ฐ€์žฅ ๋จผ์ € ๋ Œ๋”๋ง
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
- def show_best(p=1):
 
 
 
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, inputs=[bp], outputs=[out, bp])
562
-
563
- # ์ดˆ๊ธฐ ๋กœ๋“œ
564
- demo.load(show_best, outputs=[out, bp])
565
-
566
- return demo
567
 
568
- app = build()
 
569
 
570
- if __name__ == "__main__":
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