Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion robit/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Config:
VERSION: str = '0.4.8'
VERSION: str = '0.4.9'
TIMEZONE: str = 'UTC'
LOG_FILE_NAME: str = 'robit'
LOG_BACKUP_DAYS: int = 7
Expand Down
25 changes: 16 additions & 9 deletions robit/web_server/server.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
from __future__ import annotations

import threading
from typing import Optional

from http.server import HTTPServer
from time import sleep

from robit.web_server.request_handler import WebRequestHandler


class WebServer:
def __init__(
self,
address: str = 'localhost',
port: int = 8000,
key: Optional[str] = None,
html_replace_dict: Optional[dict] = None
self,
address: str = 'localhost',
port: int = 8000,
key: str | None = None,
html_replace_dict: dict | None = None
) -> None:
self.api_dict = dict()
self.post_dict = dict()
self.api_dict = {}
self.post_dict = {}

self.address = address
self.port = port
Expand Down Expand Up @@ -42,13 +45,14 @@ def start(self) -> None:
threading.Thread(target=self.update_api_dict).start()

href_link = f'http://{self.address}:{self.port}'

if self.key:
href_link += f'/{self.key}/'

print(f'Starting httpd server at {href_link}')

if self.key is None:
print(f'We do not recommend running servers with out keys!')
print('We do not recommend running servers with out keys!')

def stop(self) -> None:
pass
Expand All @@ -57,5 +61,8 @@ def update_api_dict(self) -> None:
while True:
if self.worker_conn.poll():
update_dict = self.worker_conn.recv()

for key, val in update_dict.items():
self.api_dict[key] = val

sleep(1.0)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = robit
version = 0.4.8
version = 0.4.9
author = Nathan Johnson
author_email = nathanj@stratusadv.com
description = Service Worker Framework
Expand Down