Skip to content

Instantly share code, notes, and snippets.

@daiiz
Last active April 24, 2016 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daiiz/6c4c6cd3564d77ad0213a5eb103df8de to your computer and use it in GitHub Desktop.
Save daiiz/6c4c6cd3564d77ad0213a5eb103df8de to your computer and use it in GitHub Desktop.
A local server for tfPhotoPalette
# coding: utf-8
from flask import Flask, request, jsonify
import urllib
app = Flask(__name__)
def getPhoto (received_json):
return {
"base64jpg": received_json['jpg'],
"jpg" : urllib.urlopen(received_json['jpg']).read(),
"type": received_json['photo_type']
}
# tfPhotoPaletteからデータを受信
@app.route('/api/classify', methods=['POST'])
def classify ():
# 受信した画像情報
photo = getPhoto(request.json)
#
# ここに処理を記述
#
scores = {"photo_type": photo["type"]}
# tfPhotoPaletteに結果を返却
return jsonify(theme="", scores=scores, description="Palette Server")
if __name__ == '__main__':
app.run(port=52892)