MCPcopy Create free account
hub / github.com/RocketMap/RocketMap / Pogom

Class Pogom

pogom/app.py:23–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23class Pogom(Flask):
24 def __init__(self, import_name, **kwargs):
25 super(Pogom, self).__init__(import_name, **kwargs)
26 compress.init_app(self)
27 self.json_encoder = CustomJSONEncoder
28 self.route("/", methods=['GET'])(self.fullmap)
29 self.route("/raw_data", methods=['GET'])(self.raw_data)
30 self.route("/loc", methods=['GET'])(self.loc)
31 self.route("/next_loc", methods=['POST'])(self.next_loc)
32 self.route("/mobile", methods=['GET'])(self.list_pokemon)
33 self.route("/search_control", methods=['GET'])(self.get_search_control)
34 self.route("/search_control", methods=['POST'])(self.post_search_control)
35 self.route("/stats", methods=['GET'])(self.get_stats)
36 self.route("/status", methods=['GET'])(self.get_status)
37 self.route("/status", methods=['POST'])(self.post_status)
38
39 def set_search_control(self, control):
40 self.search_control = control
41
42 def set_location_queue(self, queue):
43 self.location_queue = queue
44
45 def set_current_location(self, location):
46 self.current_location = location
47
48 def get_search_control(self):
49 return jsonify({'status': not self.search_control.is_set()})
50
51 def post_search_control(self):
52 args = get_args()
53 if not args.search_control:
54 return 'Search control is disabled', 403
55 action = request.args.get('action', 'none')
56 if action == 'on':
57 self.search_control.clear()
58 log.info('Search thread resumed')
59 elif action == 'off':
60 self.search_control.set()
61 log.info('Search thread paused')
62 else:
63 return jsonify({'message': 'invalid use of api'})
64 return self.get_search_control()
65
66 def fullmap(self):
67 args = get_args()
68 fixed_display = "none" if args.fixed_location else "inline"
69 search_display = "inline" if args.search_control else "none"
70
71 return render_template('map.html',
72 lat=self.current_location[0],
73 lng=self.current_location[1],
74 gmaps_key=config['GMAPS_KEY'],
75 lang=config['LOCALE'],
76 is_fixed=fixed_display,
77 search_control=search_display
78 )
79
80 def raw_data(self):

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected