things can be pointed at with the map
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 300 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 688 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 165 KiB |
+24
-1
@@ -6,7 +6,9 @@ from functools import wraps
|
||||
from sqlalchemy.sql import select
|
||||
from sqlalchemy.sql import text
|
||||
from flask import Flask
|
||||
from flask import render_template, send_from_directory, request, Response
|
||||
from flask import render_template, send_from_directory, request, Response, send_file
|
||||
from PIL import Image, ImageDraw
|
||||
from io import BytesIO
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
import pprint
|
||||
@@ -38,6 +40,12 @@ def requires_auth(f):
|
||||
return f(*args, **kwargs)
|
||||
return decorated
|
||||
|
||||
def serveImage(img):
|
||||
img_io = BytesIO()
|
||||
img.save(img_io, 'PNG')
|
||||
img_io.seek(0)
|
||||
return send_file(img_io, mimetype='image/png')
|
||||
|
||||
@app.route('/parts')
|
||||
def index():
|
||||
return render_template('partsearch.html')
|
||||
@@ -96,6 +104,21 @@ def query(filter_dummy, query):
|
||||
r.close()
|
||||
return json.dumps(l)
|
||||
|
||||
@app.route('/parts/map/<mapurl>')
|
||||
def getMap(mapurl):
|
||||
try:
|
||||
mapimage = Image.open('maps/' + mapurl)
|
||||
except FileNotFoundError:
|
||||
return serveImage(Image.open("maps/404.png"))
|
||||
if request.args.get('x') is not None and request.args.get('y') is not None:
|
||||
x = int(request.args.get('x'))
|
||||
y = int(request.args.get('y'))
|
||||
pointer = Image.open('maps/here.png')
|
||||
width, height = pointer.size
|
||||
mapimage.paste(pointer, (x - int(width/2), y-int(height/2)), pointer)
|
||||
return serveImage(mapimage)
|
||||
|
||||
|
||||
@app.route('/parts/getfile/<filename>')
|
||||
def getfile(filename):
|
||||
if(re.match('^[\w\-_]+$', filename) == None):
|
||||
|
||||
Reference in New Issue
Block a user