59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
#
|
|
# CatNet Python Server
|
|
#
|
|
# Copyright (C) 2023-2024 John Solntsev
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
import logging
|
|
import os
|
|
|
|
from .common import HandlerType, HTTPMethod
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class Path:
|
|
def __init__(self, address, handler_type=HandlerType.STATIC_FILE, link="index.html", methods=HTTPMethod.GET):
|
|
self.address = address
|
|
self.handler_type = handler_type
|
|
self.link = link
|
|
self.methods = methods
|
|
|
|
def check_method(self, method):
|
|
return method in self.methods
|
|
|
|
@property
|
|
def handler_type(self):
|
|
return self._handler_type
|
|
|
|
@handler_type.setter
|
|
def handler_type(self, value):
|
|
if not isinstance(value, HandlerType):
|
|
raise ValueError
|
|
|
|
self._handler_type = value
|
|
|
|
@property
|
|
def methods(self):
|
|
return self._methods
|
|
|
|
@methods.setter
|
|
def methods(self, value):
|
|
if not isinstance(value, HTTPMethod):
|
|
raise ValueError
|
|
|
|
self._methods = value
|