""" Main SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2021 Project Author name guillermo.gutierrezmorote@concordia.ca Project Collaborator name peteryefi@gmail.com """ import flask import yaml from flask_restful import Api from hub_api.city_info import CityInfo, City from hub_api.session import SessionStart, SessionEnd, KeepSessionAlive from hub_api.uptime import Uptime from hub_api.user import User, UserLogin from flasgger import LazyJSONEncoder, Swagger from flask import Response app = flask.Flask('gamification') app.json_encoder = LazyJSONEncoder api = Api(app) with open("hub_api/docs/openapi-specs.yml", "r") as stream: swagger_config = { "headers": [], "specs": [ { "endpoint": 'apispec', "route": '/apispec.json', "rule_filter": lambda rule: True, # all in "model_filter": lambda tag: True, # all in } ], "static_url_path": "/flasgger_static", "specs_route": "/api-docs/", "openapi": "3.0.0" } try: Swagger(app, template=yaml.safe_load(stream), config=swagger_config) except yaml.YAMLError as exc: print(exc) api.add_resource(Uptime, '/v1.4/uptime') api.add_resource(User, '/v1.4/user') api.add_resource(UserLogin, '/v1.4/user/login') api.add_resource(SessionStart, '/v1.4/session/start') api.add_resource(SessionEnd, '/v1.4/session/end') api.add_resource(KeepSessionAlive, '/v1.4/session/keep_alive') api.add_resource(CityInfo, '/v1.4/city/') api.add_resource(City, '/v1.4/city') @app.route("/") def home(): return Response(headers={'Access-Control-Allow-Origin': '*'}) if __name__ == '__main__': app.run(port=15789, host="0.0.0.0", debug=False)