File size: 1,098 Bytes
deb8fc1
 
57989d0
deb8fc1
57989d0
deb8fc1
 
 
 
 
 
57989d0
 
 
 
 
 
 
 
 
deb8fc1
4c0c0cc
deb8fc1
 
 
 
 
57989d0
deb8fc1
 
 
 
 
 
 
 
57989d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import subprocess
import gradio as gr
from flask import Flask, send_from_directory

# Clone the Mario game repository
def install_package():
    subprocess.run(["git", "clone", "https://github.com/reruns/mario.git", "mario"], check=True)

# Install the game files on startup
install_package()

# Create a Flask app to serve static files
flask_app = Flask(__name__)

# Serve static files (JavaScript, CSS, assets, etc.)
@flask_app.route("/mario/<path:path>")
def serve_static(path):
    return send_from_directory("mario", path)

# Read the index.html file
def serve_game():
    with open("mario/index.html", "r") as file:
        html_content = file.read()
    return html_content

# Create a Gradio interface
iface = gr.Interface(
    fn=serve_game,  # Function to generate the HTML content
    inputs=None,    # No inputs needed
    outputs=gr.HTML(),  # Output is HTML content
    live=True,      # Keep the interface live
    title="Mario HTML Game",
    description="Play the Mario HTML game embedded in Gradio!"
)

# Launch the Gradio app
iface.launch(server_name="0.0.0.0", server_port=7860)