Skip to content
Open
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
17 changes: 7 additions & 10 deletions robyn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,25 @@ def _normalize_endpoint(endpoint: str) -> str:
return endpoint.rstrip("/")


config = Config()

if (compile_path := config.compile_rust_path) is not None:
compile_rust_files(compile_path)
print("Compiled rust files")


class BaseRobyn(ABC):
"""This is the python wrapper for the Robyn binaries."""

def __init__(
self,
file_object: str,
config: Config = Config(),
config: Optional[Config] = None,
openapi_file_path: Optional[str] = None,
openapi: Optional[OpenAPI] = None,
dependencies: DependencyMap = DependencyMap(),
) -> None:
self.config = Config() if config is None else config
if (compile_path := self.config.compile_rust_path) is not None:
compile_rust_files(compile_path)
self.config.compile_rust_path = None

directory_path = os.path.dirname(os.path.abspath(file_object))
self.file_path = file_object
self.directory_path = directory_path
self.config = config
self.dependencies = dependencies
self.openapi = openapi

Expand Down Expand Up @@ -640,7 +637,7 @@ def start(self, host: str = "127.0.0.1", port: int = 8080, _check_port: bool = T


class SubRouter(BaseRobyn):
def __init__(self, file_object: str, prefix: str = "", config: Config = Config(), openapi: OpenAPI = OpenAPI()) -> None:
def __init__(self, file_object: str, prefix: str = "", config: Optional[Config] = None, openapi: OpenAPI = OpenAPI()) -> None:
super().__init__(file_object=file_object, config=config, openapi=openapi)
self.prefix = prefix

Expand Down