Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Commit

Permalink
Change all 204 to 200
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Wang committed May 6, 2017
1 parent 1ff290f commit 8ec8c96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions restapi/backend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Provides the routes for the application."""

import base64
import os
from datetime import datetime, timedelta

Expand Down Expand Up @@ -49,7 +50,7 @@ class Media(db.Model):
@app.route('/', methods=["GET"])
def test():
"""Return a test for root route."""
return "Test succeeded. It works!", 204
return "Test succeeded. It works!", 200


@app.route('/api/media/<filename>', methods=["GET"])
Expand Down Expand Up @@ -147,8 +148,10 @@ def getRelevant():
for i in Media.query.filter(Media.startDate > startTime):
tempDict = dict()

turl = base64.b64decode(circlise.getProfilePic(i.uid)).decode('utf-8')

tempDict['url'] = "/" + app.config["UPLOAD_FOLDER"] + "/" + i.filename
tempDict['thumbUrl'] = circlise.getProfilePic(i.uid)
tempDict['thumbUrl'] = turl
tempDict['type'] = i.mediaType
tempDict['lat'] = i.lat
tempDict['lon'] = i.lon
Expand Down
Empty file added restapi/media/thumbs/.gitkeep
Empty file.
10 changes: 6 additions & 4 deletions restapi/utils/circlise.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from PIL import Image, ImageDraw, ImageOps

from . import upload


def getProfilePic(userID):
"""Return compressed version of a user's profile pic."""
Expand All @@ -25,9 +27,9 @@ def getProfilePic(userID):
mask = mask.resize(im.size, Image.ANTIALIAS)
im.putalpha(mask)

fn = upload.hashfile('hardcoding_hullo.png')

# Save the file as a base 64 string.
buffer = BytesIO()
im.save(buffer, format="PNG")
img_str = base64.b64encode(buffer.getvalue())
im.save('/media/thumbs/' + fn, format="PNG")

return img_str
return "/media/thumbs/" + fn

0 comments on commit 8ec8c96

Please sign in to comment.