Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Directory structure setup for Streamlit + Colab
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# Create directories
|
| 5 |
+
base_dir = "/mnt/data/mini_game_arcade"
|
| 6 |
+
os.makedirs(base_dir, exist_ok=True)
|
| 7 |
+
|
| 8 |
+
# List of game filenames
|
| 9 |
+
games = [
|
| 10 |
+
"rock_paper_scissors.py",
|
| 11 |
+
"guess_the_number.py",
|
| 12 |
+
"word_scramble.py",
|
| 13 |
+
"emoji_quiz.py",
|
| 14 |
+
"score_tracker.py",
|
| 15 |
+
"hangman.py",
|
| 16 |
+
"tic_tac_toe.py",
|
| 17 |
+
"math_quiz.py",
|
| 18 |
+
"typing_speed_test.py",
|
| 19 |
+
"color_guess.py"
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
# Create placeholder files
|
| 23 |
+
for game in games:
|
| 24 |
+
game_path = os.path.join(base_dir, game)
|
| 25 |
+
with open(game_path, "w") as f:
|
| 26 |
+
f.write(f"# {game.split('.')[0].replace('_', ' ').title()} Game Logic\n")
|
| 27 |
+
|
| 28 |
+
# Create main app.py
|
| 29 |
+
main_app_code = """
|
| 30 |
+
import streamlit as st
|
| 31 |
+
|
| 32 |
+
st.set_page_config(page_title="🎮 Mini Game Arcade", layout="centered")
|
| 33 |
+
st.title("🎮 Welcome to the Mini Game Arcade!")
|
| 34 |
+
st.markdown("Select a game from the dropdown menu to start playing:")
|
| 35 |
+
|
| 36 |
+
games = {
|
| 37 |
+
"Rock Paper Scissors": "rock_paper_scissors",
|
| 38 |
+
"Guess the Number": "guess_the_number",
|
| 39 |
+
"Word Scramble": "word_scramble",
|
| 40 |
+
"Emoji Quiz": "emoji_quiz",
|
| 41 |
+
"Score Tracker": "score_tracker",
|
| 42 |
+
"Hangman": "hangman",
|
| 43 |
+
"Tic Tac Toe": "tic_tac_toe",
|
| 44 |
+
"Math Quiz": "math_quiz",
|
| 45 |
+
"Typing Speed Test": "typing_speed_test",
|
| 46 |
+
"Color Guess": "color_guess"
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
selected_game = st.selectbox("Choose a game", list(games.keys()))
|
| 50 |
+
|
| 51 |
+
if selected_game:
|
| 52 |
+
game_module = games[selected_game]
|
| 53 |
+
exec(open(f"/mnt/data/mini_game_arcade/{game_module}.py").read())
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
# Write the main app file
|
| 57 |
+
main_app_path = os.path.join(base_dir, "app.py")
|
| 58 |
+
with open(main_app_path, "w") as f:
|
| 59 |
+
f.write(main_app_code)
|
| 60 |
+
|
| 61 |
+
base_dir # Return the path to the created structure
|