Skip to content

Commit 5cf5b0b

Browse files
committed
Update to Rust API
1 parent ef2b58d commit 5cf5b0b

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/app.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def homepage():
1414

1515
@app.route('/catalog')
1616
def catalogpage():
17-
games = requests.get(app.config["DEVCADE_API_URI"] + "games/gamelist").json()
17+
games = requests.get(app.config["DEVCADE_API_URI"] + "games/").json()
1818
return flask.render_template('catalog.html', gamelist=games)
1919

2020
@app.route('/user')
@@ -26,13 +26,10 @@ def user():
2626

2727
@app.route('/game/<id>')
2828
def getgame(id):
29-
games = requests.get(app.config["DEVCADE_API_URI"] + "games/gamelist").json()
30-
for i in range(len(games)):
31-
if games[i]['id'] == id:
32-
break
33-
else:
29+
game_req = requests.get(app.config["DEVCADE_API_URI"] + f"games/{id}")
30+
if game_req.status_code == 404:
3431
flask.render_template('404.html')
35-
return flask.render_template('game.html', game=games[i])
32+
return flask.render_template('game.html', game=game_req.json())
3633

3734
@app.route('/upload_game', methods = ['POST'])
3835
@login_required
@@ -44,7 +41,7 @@ def uploadgame():
4441
author = current_user.id
4542
file = {'file': ("game.zip", f.stream, "application/zip")}
4643
fields = {'title': title, 'description': description, 'author':author}
47-
r = requests.post(app.config["DEVCADE_API_URI"] + "games/upload", files=file, data=fields)
44+
r = requests.post(app.config["DEVCADE_API_URI"] + "games/", files=file, data=fields)
4845
if r.status_code == 200:
4946
return flask.redirect('/catalog')
5047
return "<p>" + r.text + "</p>"
@@ -54,7 +51,7 @@ def uploadgame():
5451
def uploadpage():
5552
usergames = []
5653
try:
57-
games = requests.get(app.config["DEVCADE_API_URI"] + "games/gamelist").json()
54+
games = requests.get(app.config["DEVCADE_API_URI"] + "games/").json()
5855
for i in games:
5956
if i['author'] == current_user.id:
6057
usergames.append(i)
@@ -64,21 +61,18 @@ def uploadpage():
6461

6562
@app.route('/download/<id>')
6663
def download(id):
67-
r = requests.get(app.config["DEVCADE_API_URI"] + "games/download/" + id, stream=True)
64+
r = requests.get(app.config["DEVCADE_API_URI"] + f"games/{id}/game", stream=True)
6865
b = BytesIO(r.content)
6966
game = FileWrapper(b)
7067
return flask.Response(game, mimetype="application/zip", direct_passthrough=True)
7168

7269
@app.route('/admin/delete/<id>')
7370
@login_required
7471
def deleteGame(id):
75-
games = requests.get(app.config['DEVCADE_API_URI'] + "games/gamelist").json()
76-
author = ""
77-
for i in games:
78-
if i['id'] == id:
79-
author = i['author']
72+
game = requests.get(app.config['DEVCADE_API_URI'] + "games/" + id).json()
73+
author = game['author']
8074
if(current_user.admin or current_user.id == author):
81-
r = requests.post(app.config["DEVCADE_API_URI"] + "games/delete/" + id)
75+
r = requests.delete(app.config["DEVCADE_API_URI"] + "games/" + id)
8276
if r.status_code != 200:
8377
return r.text
8478
else:

src/contributors.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,11 @@
7878
"link" : "",
7979
"email" : hashlib.md5(b"[email protected]").hexdigest(),
8080
"desc" : "Hardware Team, First Year GDD"
81+
},
82+
{
83+
"name" : "Joe Abbate",
84+
"link" : "https://joeabbate.me",
85+
"email" : hashlib.md5(b"[email protected]").hexdigest(),
86+
"desc" : "Lead Security Engineer, Third Year Cyber Security"
8187
}
82-
]
88+
]

0 commit comments

Comments
 (0)