-
Notifications
You must be signed in to change notification settings - Fork 0
/
appsrv.py
67 lines (49 loc) · 1.7 KB
/
appsrv.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
from flask import Flask, Response, request, send_from_directory
from fraktal import Drawing
app = Flask(__name__)
@app.route('/', defaults={'filename': 'index.html'})
@app.route('/<path:filename>')
def srv_app(filename):
resp = send_from_directory('app', filename)
resp.access_control_allow_origin='*'
return resp
@app.route('/wmts/<path:path>')
def wmts(path):
p = path.rstrip('.png').split('/')
par = { "x_row": int(p[-2]),
"y_row": int(p[-1]),
"zoomlevel": int(p[-3]),
"style": p[1],
"fractal": p[0] }
if (len(p)==7):
if (p[2]=='undefined'):
par["c"]=0
else:
par["c"]=complex(float(p[2]),
float(p[3]))
png = Drawing.generate_image_wmts_tile(par)
resp = Response(png, mimetype='image/png')
resp.access_control_allow_origin='*'
return resp
@app.route('/wms/')
def wms():
p = request.args
#def filter_neg_dict(d: dict, keys: list):
# return {k: v for k, v in d.items() if k not in keys}
#
#p = filter_neg_dict(p, ['SERVICE','VERSION','REQUEST'])
#p = filter_neg_dict(p, ['FORMAT','TRANSPARENT','CRS'])
par = { "fractal": p["LAYERS"],
"style": p["STYLES"],
"width": int(p["WIDTH"]),
"height": int(p["HEIGHT"]) }
par["xmin"], par["ymin"], par["xmax"], par["ymax"] = map(float, p["BBOX"].split(','))
if (("CX" and "CY") in p.keys()):
par["c"] = complex(float(p["CX"]),
float(p["CY"]))
png = Drawing.generate_image_wms(par)
resp = Response(png, mimetype='image/png')
resp.access_control_allow_origin='*'
return resp
if __name__ == "__main__":
app.run()