|
@@ -2,8 +2,14 @@
|
|
|
import json
|
|
import json
|
|
|
import urllib
|
|
import urllib
|
|
|
import datetime
|
|
import datetime
|
|
|
|
|
+import os
|
|
|
|
|
+
|
|
|
from db import db
|
|
from db import db
|
|
|
-from flask import Flask, jsonify, request
|
|
|
|
|
|
|
+from flask import Flask, jsonify, request, send_file
|
|
|
|
|
+
|
|
|
|
|
+from wand.image import Image
|
|
|
|
|
+from wand.drawing import Drawing
|
|
|
|
|
+from wand.color import Color
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
|
PORT = 8981
|
|
PORT = 8981
|
|
@@ -55,5 +61,26 @@ def confirm(_hash, pedidoid):
|
|
|
d.confirm(_hash, pedidoid)
|
|
d.confirm(_hash, pedidoid)
|
|
|
return "{}"
|
|
return "{}"
|
|
|
|
|
|
|
|
|
|
+@app.route(BASE_PATH + '/image/<_hash>')
|
|
|
|
|
+def image(_hash):
|
|
|
|
|
+ filename = '/var/www/pedido/back/images/%s.png' % _hash
|
|
|
|
|
+ if not os.path.isfile(filename) or True:
|
|
|
|
|
+ c=d.client(_hash)
|
|
|
|
|
+ draw = Drawing()
|
|
|
|
|
+ with Image(width=300,height=150,background=Color('#2A3A49')) as img:
|
|
|
|
|
+ with Image(filename="/var/www/pedido/back/images/logo.png") as logo:
|
|
|
|
|
+ img.composite(logo, left=int(img.width/2-logo.width/2), top=int(img.height/2-logo.height/2))
|
|
|
|
|
+
|
|
|
|
|
+ draw.fill_color = Color('white')
|
|
|
|
|
+ draw.gravity = "north"
|
|
|
|
|
+ draw.text(0,10, "Pedido")
|
|
|
|
|
+
|
|
|
|
|
+ draw.gravity = "south"
|
|
|
|
|
+ draw.text(0,10, c["nombre"] + " " + c["apellido"])
|
|
|
|
|
+
|
|
|
|
|
+ draw(img)
|
|
|
|
|
+ img.save(filename=filename)
|
|
|
|
|
+ return send_file(filename, mimetype='image/png')
|
|
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
app.run(host="0.0.0.0",port=PORT, debug=True)
|
|
app.run(host="0.0.0.0",port=PORT, debug=True)
|