2023-01-10 17:24:26 -05:00
|
|
|
"""
|
|
|
|
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
|
2023-01-16 15:31:02 -05:00
|
|
|
import yaml
|
2023-01-10 17:24:26 -05:00
|
|
|
from flask_restful import Api
|
2023-01-13 12:01:13 -05:00
|
|
|
from hub_api.city_info import CityInfo, City
|
2023-01-10 17:24:26 -05:00
|
|
|
from hub_api.session import SessionStart, SessionEnd, KeepSessionAlive
|
|
|
|
from hub_api.uptime import Uptime
|
2023-01-11 19:56:51 -05:00
|
|
|
from hub_api.user import User, UserLogin
|
2023-01-17 19:15:18 -05:00
|
|
|
from hub_api.city_commands import SaveCity, UpdateCity, DeleteCity, ListCities, SearchCity
|
2023-01-17 19:02:49 -05:00
|
|
|
from flasgger import LazyJSONEncoder, Swagger
|
2023-01-30 19:45:02 -05:00
|
|
|
from flask import Response
|
2023-01-10 17:24:26 -05:00
|
|
|
|
|
|
|
app = flask.Flask('gamification')
|
2023-01-16 15:31:02 -05:00
|
|
|
app.json_encoder = LazyJSONEncoder
|
2023-01-10 17:24:26 -05:00
|
|
|
api = Api(app)
|
|
|
|
|
2023-01-16 15:31:02 -05:00
|
|
|
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)
|
|
|
|
|
2023-01-10 17:24:26 -05:00
|
|
|
api.add_resource(Uptime, '/v1.4/uptime')
|
|
|
|
api.add_resource(User, '/v1.4/user')
|
2023-01-11 19:56:51 -05:00
|
|
|
api.add_resource(UserLogin, '/v1.4/user/login')
|
2023-01-10 17:24:26 -05:00
|
|
|
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')
|
2023-01-17 19:02:49 -05:00
|
|
|
api.add_resource(CityInfo, '/v1.4/city/<int:city_id>')
|
2023-01-13 12:01:13 -05:00
|
|
|
api.add_resource(City, '/v1.4/city')
|
2023-01-17 19:15:18 -05:00
|
|
|
api.add_resource(SaveCity, '/v1.4/city/save_city')
|
|
|
|
api.add_resource(UpdateCity, '/v1.4/city/update_city')
|
|
|
|
api.add_resource(DeleteCity, '/v1.4/city/delete_city')
|
|
|
|
api.add_resource(ListCities, '/v1.4/city/list_cities')
|
|
|
|
api.add_resource(SearchCity, '/v1.4/city/search_city')
|
2023-01-10 17:24:26 -05:00
|
|
|
api.add_resource(Greenery, '/v1.4/greenery')
|
2023-01-17 19:15:18 -05:00
|
|
|
|
2023-01-30 19:45:02 -05:00
|
|
|
|
|
|
|
@app.route("/")
|
|
|
|
def home():
|
|
|
|
return Response(headers={'Access-Control-Allow-Origin': '*'})
|
|
|
|
|
|
|
|
|
2023-02-01 15:48:14 -05:00
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run(port=15789, host="0.0.0.0", debug=False)
|
2023-02-02 14:27:02 -05:00
|
|
|
>>>>>>> main
|