Skip to content

Commit c7f75ab

Browse files
committed
dynamic game routes on app.py with images
1 parent 6e09fb2 commit c7f75ab

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

app.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from flask import Flask, render_template
1+
from flask import Flask, render_template, request, jsonify
2+
from game_data import game_pages # Import the game_pages dictionary
23

34
app = Flask(__name__)
45

5-
# List of game names (without the .html extension)
6-
game_pages = ['cs2', 'arma3', 'dst', 'factorio', 'eco', 'minecraftJava']
7-
86
@app.route('/')
97
def home():
108
return render_template('home.html', game_pages=game_pages)

game_data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
game_pages = {
2+
'cs2': 'https://cdn.cloudflare.steamstatic.com/steam/apps/730/library_600x900.jpg',
3+
'factorio': 'https://cdn.cloudflare.steamstatic.com/steam/apps/427520/library_600x900.jpg?t=1597145422'
4+
# Add more games here as needed
5+
}

templates/home.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ <h1>WebGSM</h1>
1616
</div>
1717
<div class="grid-container">
1818
<div class="content">
19-
<a id="cs2-button" href="{{ url_for('cs2') }}">
20-
<img class="game-button" src="https://cdn.cloudflare.steamstatic.com/steam/apps/730/library_600x900.jpg?t=1695852468" alt="CS2 Poster">
21-
</a>
19+
<!-- Loop through game pages and create buttons with their respective images -->
20+
{% for game, image_url in game_pages.items() %}
21+
<a href="{{ url_for('game', game_name=game) }}">
22+
<img class="game-button" src="{{ image_url }}" alt="{{ game }} Poster">
23+
</a>
24+
{% endfor %}
2225
</div>
2326
</div>
2427
</body>

0 commit comments

Comments
 (0)