# Path: akamatsu/models.py
# class FileUpload(BaseModel):
#     """Model for static file uploads.
# 
#     Attributes:
#         id (int): Unique ID of the record.
#         path (str): Path to the file relative to the uploads directory.
#         description (str): Optional description of the file.
#         uploaded_at (datetime): UTC datetime in which the file was uploaded.
#     """
#     __tablename__ = 'uploads'
# 
#     id = db.Column(db.Integer, primary_key=True)
# 
#     path = db.Column(db.String(255), nullable=False, unique=True)
#     description = db.Column(db.String(256), nullable=True)
#     mime = db.Column(db.String(128), nullable=False)
#     uploaded_at = db.Column(
#         db.DateTime,
#         nullable=False,
#         default=datetime.datetime.utcnow()
#     )
# 
# 
#     @classmethod
#     def get_by_path(cls, path):
#         """Get instance by path.
# 
#         Returns:
#             Instance or `None` if not found.
#         """
#         return cls.query.filter_by(path=path).first()


import os
from flask import Blueprint, current_app, make_response, send_from_directory
from werkzeug.utils import secure_filename
from akamatsu.models import FileUpload
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""This file contains common views."""





bp_common = Blueprint('common', __name__)


@bp_common.route('/_uploads/<path:filename>')
def serve_file(filename):
    """Serve the given uploaded file.

    Args:
        filename (str): Relative file path.
    """

# Path: akamatsu/models.py
# class FileUpload(BaseModel):
#     """Model for static file uploads.
# 
#     Attributes:
#         id (int): Unique ID of the record.
#         path (str): Path to the file relative to the uploads directory.
#         description (str): Optional description of the file.
#         uploaded_at (datetime): UTC datetime in which the file was uploaded.
#     """
#     __tablename__ = 'uploads'
# 
#     id = db.Column(db.Integer, primary_key=True)
# 
#     path = db.Column(db.String(255), nullable=False, unique=True)
#     description = db.Column(db.String(256), nullable=True)
#     mime = db.Column(db.String(128), nullable=False)
#     uploaded_at = db.Column(
#         db.DateTime,
#         nullable=False,
#         default=datetime.datetime.utcnow()
#     )
# 
# 
#     @classmethod
#     def get_by_path(cls, path):
#         """Get instance by path.
# 
#         Returns:
#             Instance or `None` if not found.
#         """
#         return cls.query.filter_by(path=path).first()


# Path: akamatsu/views/common.py
import os
from flask import Blueprint, current_app, make_response, send_from_directory
from werkzeug.utils import secure_filename
from akamatsu.models import FileUpload

# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""This file contains common views."""





bp_common = Blueprint('common', __name__)


@bp_common.route('/_uploads/<path:filename>')
def serve_file(filename):
    """Serve the given uploaded file.

    Args:
        filename (str): Relative file path.
    """

    fupload = FileUpload.get_by_path(filename)