api.py 880 Bytes
Newer Older
1
from flask import Flask
James Kirk's avatar
James Kirk committed
2
from flask_cors import CORS
3
from flask_restful import Api
James Kirk's avatar
James Kirk committed
4

5
from endpoints.clients import Client, ClientList
James Kirk's avatar
James Kirk committed
6
from endpoints.notify import Notify
7
from endpoints.receive import Receive
8
from endpoints.send import Send
9 10 11
from endpoints.token import Token
from models.token import TokenModel

12 13
import os

14 15
token = TokenModel()
token.setSecret()
16 17 18

app = Flask(__name__)
api = Api(app)
19
CORS(app, resources={r"*": {"origins": "http://localhost:8086"}})
20 21 22 23

api.add_resource(ClientList, "/client")
api.add_resource(Client, "/client/<client_id>")
api.add_resource(Receive, "/receive")
24 25
api.add_resource(Send, "/send")
api.add_resource(Notify, "/notify")
26
api.add_resource(Token, "/token")
27

28 29
flask_host = os.getenv("FLASK_HOST", "localhost") # Sets to whatever MQ_HOST is, or defaults to localhost

30
if __name__ == "__main__":
31
    app.run(debug=False, port=8087, host=flask_host)