-
Notifications
You must be signed in to change notification settings - Fork 0
/
pocket_server.py
executable file
·36 lines (25 loc) · 1003 Bytes
/
pocket_server.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
import os
from flask import Flask, request, redirect, url_for
from werkzeug.utils import secure_filename
import json
import urllib2
from site_matcher.pocket_matcher import match_site
app = Flask(__name__)
@app.route('/image', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
# save image file
b64_data = request.values['base64']
with open("/home/shakedl/PockeTour/data/input_img.jpg", "wb") as file:
file.write(b64_data.decode('base64'))
# parse gps data
gps = map(lambda cord: float(cord), json.loads(request.values['gps']))
# fetch json response
json_response = match_site("/home/shakedl/PockeTour/data/input_img.jpg", gps)
return json_response
return "failed to retrieve image"
@app.route('/test', methods=['GET', 'POST'])
def testing_conn():
return "Everything is within normal parameters captain"
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080, debug=True)