Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pygame
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
def run_game(code):
|
| 5 |
+
pygame.init()
|
| 6 |
+
screen = pygame.display.set_mode((400, 300))
|
| 7 |
+
pygame.display.set_caption("Headless Game")
|
| 8 |
+
screen.fill((0, 128, 255))
|
| 9 |
+
pygame.draw.circle(screen, (255, 0, 0), (200, 150), 75)
|
| 10 |
+
pygame.image.save(screen, "output.png")
|
| 11 |
+
pygame.quit()
|
| 12 |
+
return "output.png"
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(fn=run_game, inputs="text", outputs="image")
|
| 15 |
+
iface.launch()
|