Skip to content

Commit eecd31e

Browse files
authored
Merge pull request #14 from ComputerScienceHouse/cinnamon
Add Game Download
2 parents ddbce74 + 6a49a1e commit eecd31e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from flask_login import login_required, current_user
44
from auth import app
55
import requests
6+
from io import BytesIO
7+
from werkzeug.wsgi import FileWrapper
68

79
@app.route('/')
810
# @login_required
@@ -63,6 +65,13 @@ def uploadpage():
6365
print("api offline")
6466
return flask.render_template('upload.html', title='Devcade - Upload', gamelist=usergames)
6567

68+
@app.route('/download/<id>')
69+
def download(id):
70+
r = requests.get(app.config["DEVCADE_API_URI"] + "games/download/" + id, stream=True)
71+
b = BytesIO(r.content)
72+
game = FileWrapper(b)
73+
return flask.Response(game, mimetype="application/zip", direct_passthrough=True)
74+
6675
@app.route('/admin/delete/<id>')
6776
@login_required
6877
def deleteGame(id):

src/templates/game.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{% extends "header.html" %} {% block title %}Devcade - {{game.name}}
22
{%endblock %} {% block content %}
33
<div class="card-wrapper">{{ gamecard(game) }}</div>
4+
<div class="card-wrapper">
5+
<a class="btn btn-red" href="/download/{{ game.id }}">Download Game</a>
6+
</div>
47
{% if current_user.admin or current_user.id == game.author %}
8+
<h2>Admin stuff:</h2>
59
<div class="card-wrapper">
610
<a class="btn btn-red" href="/edit/{{ game.id }}">Edit</a>
711
<a class="btn btn-red" href="/admin/delete/{{ game.id }}">Delete</a>

0 commit comments

Comments
 (0)