foldsite/main.py
Tanishq Dubey c33a415a8d
All checks were successful
Datadog Software Composition Analysis / Datadog SBOM Generation and Upload (push) Successful in 14s
Datadog Static Analysis / Datadog Static Analyzer (push) Successful in 23s
sync uv deps
2025-03-01 09:11:16 -05:00

42 lines
1.4 KiB
Python

from src.server.server import Server
from src.routes.routes import RouteManager
from src.config.args import create_parser
from src.config.config import Configuration
from src.rendering.helpers import TemplateHelpers
from src.server.file_manager import create_filemanager_blueprint
def main():
parser = create_parser()
args = parser.parse_args()
c = Configuration(args.config)
c.load_config()
r = RouteManager(c)
t = TemplateHelpers(c)
server = Server()
server.register_template_function("get_sibling_content_files", t.get_sibling_content_files)
server.register_template_function("get_text_document_preview", t.get_text_document_preview)
server.register_template_function("get_sibling_content_folders", t.get_sibling_content_folders)
server.register_template_function("get_folder_contents", t.get_folder_contents)
server.register_route("/styles/<path:path>", r.get_style)
server.register_route("/download/<path:path>", r.get_static)
server.register_route("/", r.default_route, defaults={"path": ""})
server.register_route("/<path:path>", r.default_route)
file_manager_bp = create_filemanager_blueprint(c.content_dir, url_prefix='/admin', auth_password="password")
server.app.register_blueprint(file_manager_bp)
try:
server.run()
except Exception as e:
print(e)
if __name__ == "__main__":
main()