30 lines
1005 B
Python
30 lines
1005 B
Python
|
"""
|
||
|
Geometry
|
||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||
|
Copyright © 2022 Project Author name guillermo.gutierrezmorote@concordia.ca
|
||
|
"""
|
||
|
|
||
|
import json
|
||
|
from flask import make_response, send_file, request, Response
|
||
|
from flask_restful import Resource
|
||
|
from pathlib import Path
|
||
|
|
||
|
from hub_api.helpers.session_helper import refresh_session
|
||
|
|
||
|
|
||
|
class Geometry(Resource):
|
||
|
def __init__(self):
|
||
|
data_path = (Path(__file__).parent.parent / 'data').resolve()
|
||
|
self._gtlf_path = (Path(data_path / 'DomparkBuilding.gltf')).resolve()
|
||
|
|
||
|
def get(self):
|
||
|
session = refresh_session(request)
|
||
|
if session is None:
|
||
|
return Response(json.dumps({'error': 'invalid session'}), status=401)
|
||
|
response = make_response(send_file(self._gtlf_path,
|
||
|
as_attachment=True,
|
||
|
mimetype='model/gltf+json, model/gltf-binary'))
|
||
|
response.headers['session_id'] = session.id
|
||
|
response.headers['token'] = session.token
|
||
|
return response
|