from flask import Flask
from flask_cors import CORS
from flask_restful import Api

from endpoints.clients import Client, ClientList
from endpoints.notify import Notify
from endpoints.receive import Receive
from endpoints.send import Send
from endpoints.token import Token
from models.token import TokenModel

token = TokenModel()
token.setSecret()

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

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

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