forked from SchattenGenie/apn_utxo_server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (32 loc) · 937 Bytes
/
main.py
File metadata and controls
37 lines (32 loc) · 937 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import config
from bd import redis, add_wallet_to_db
from pusher import create_apn_service, start_background_push_notifications
from flask import Flask, jsonify
from flask import request as frequest
import json
app = Flask(__name__)
@app.route('/subscribe', methods=['POST'])
def route_server():
"""
Add new wallet with POST
"""
wallet_raw = json.loads(frequest.data)
wallet = {}
try:
wallet['address'] = wallet_raw['address']
wallet['device_token'] = wallet_raw['deviceToken']
except KeyError:
pass
add_wallet_to_db(wallet)
return 'true'
def main():
# init Apple Push Notification Client
config.apns = create_apn_service()
# background notifications
start_background_push_notifications()
# Flask server for registration
app.run(host=config.HOST, port=config.PORT)
if __name__ == "__main__":
main()