-
Notifications
You must be signed in to change notification settings - Fork 1
/
render.py
71 lines (59 loc) · 1.57 KB
/
render.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from flask import Blueprint, Response, abort, send_file, request
from flask import jsonify
import os
renderbp = Blueprint("render", __name__)
import json, time
import views
event = []
# the directory
d = None
# send a single render
@renderbp.route("/render")
def render():
l = d.treeiter("export")
for i in l:
data = i.info()
if i.is_leaf == True:
if i.built == True:
if i.rendered == False:
if i.pending == False:
i.pending = True
# update the view for now
data['view'] = views.placed(data['view']['scene'])
return jsonify(data)
return jsonify({"queue":"empty"})
@renderbp.route("/rendersizes")
def render_sizes():
s = d.store.get_sizes()
return jsonify(s)
# get posted image
@renderbp.route("/image", methods=["POST"])
def image():
data = None
try:
data = request.files["objs"]
except:
abort(403)
return
export_path = d.export_prefix + os.sep + "img" + os.sep
try:
os.makedir(export_path)
except:
pass
data.save(export_path + data.filename)
d.set_image(data.filename)
return "OK"
# get zipped gltf
@renderbp.route("/zipped/<modelname>")
def zipped(modelname):
v = d.get_name(modelname)
if v is None:
abort(404)
return
file_name = d.get_zipped(v)
return send_file(
file_name,
mimetype="application/zip",
as_attachment=True,
attachment_filename=v.name + ".zip",
)