Initial Structure

This commit is contained in:
2025-02-15 09:00:13 -05:00
commit de565fce4f
15 changed files with 279 additions and 0 deletions

0
src/__init__.py Normal file
View File

0
src/config/__init__.py Normal file
View File

View File

3
src/routes/__init__.py Normal file
View File

@ -0,0 +1,3 @@

3
src/routes/routes.py Normal file
View File

@ -0,0 +1,3 @@
def default_route(path: str):
return f"Default route for {path}"

0
src/server/__init__.py Normal file
View File

28
src/server/server.py Normal file
View File

@ -0,0 +1,28 @@
from flask import Flask
from typing import Callable, Dict
class Server:
def __init__(
self,
debug: bool = True,
host: str = "0.0.0.0",
port: int = 8080,
template_functions: Dict[str, Callable] = {},
):
self.debug = debug
self.host = host
self.port = port
self.app = Flask(__name__)
for name, func in template_functions.items():
self.register_template_function(name, func)
def run(self):
self.app.debug = self.debug
self.app.run(host=self.host, port=self.port)
def register_template_function(self, name, func):
self.app.jinja_env.globals.update({name: func})
def register_route(self, route, func, defaults=None):
self.app.add_url_rule(route, func.__name__, func, defaults=defaults)