30 lines
741 B
Python
30 lines
741 B
Python
__author__ = 'RemiZOffAlex'
|
|
__email__ = 'remizoffalex@mail.ru'
|
|
|
|
|
|
class Response:
|
|
def __init__(self, data, **kwargs):
|
|
self.code = 200
|
|
self.phrase = 'Success'
|
|
self.version = 'HTTP/1.1'
|
|
self.headers = {}
|
|
self.content_type = "text/plain"
|
|
self.__data = data
|
|
for key in kwargs:
|
|
if key in self.__dict__:
|
|
setattr(self, key, kwargs[key])
|
|
|
|
def __call__(self):
|
|
status = ' '.join([self.version, str(self.code), self.phrase])
|
|
crlf = b'\r\n'*2
|
|
raw = crlf.join([
|
|
status.encode(),
|
|
self.__data.encode()
|
|
])
|
|
return raw
|
|
|
|
def __getitem__(self, index):
|
|
pass
|
|
def __iter__(self):
|
|
pass
|