From d4d12d920d998ddb46e1da97ab41e12a8de40816 Mon Sep 17 00:00:00 2001 From: ditaajipratama Date: Mon, 17 Jun 2024 12:34:19 +0700 Subject: [PATCH] For templating. Including: launcher and directory config --- app/config/directory.py | 19 +++++++++++++++++++ app/core/html.py | 17 +++++++++++++++++ app/costa.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 app/config/directory.py create mode 100644 app/core/html.py create mode 100644 app/costa.py diff --git a/app/config/directory.py b/app/config/directory.py new file mode 100644 index 0000000..9f2c2d2 --- /dev/null +++ b/app/config/directory.py @@ -0,0 +1,19 @@ +from bottle import Bottle, get, static_file + +page = { + 'public' :'pages/public' +} + +app = Bottle() + +# Default staticdir + +@app.get("/css/") +def static(filepath): + return static_file(filepath, root="./static/css") + +# Template staticdir: plain + +@app.get("/templates/plain/css/") +def static(filepath): + return static_file(filepath, root="./templates/plain/static/css") diff --git a/app/core/html.py b/app/core/html.py new file mode 100644 index 0000000..d461af7 --- /dev/null +++ b/app/core/html.py @@ -0,0 +1,17 @@ +import sys +import os + +class main: + + def __init__(self): + pass + + def get_html(location): + html_dict = {} + html_page_list = os.listdir( location ) + for html_page in html_page_list: + full_path = location + "/" + html_page + html_handle = open( full_path , 'r' ) + html_raw = html_handle.read() + html_dict[html_page] = html_raw + return html_dict diff --git a/app/costa.py b/app/costa.py new file mode 100644 index 0000000..cc6b19a --- /dev/null +++ b/app/costa.py @@ -0,0 +1,30 @@ +# CostaPy +# Copyright (C) 2022 Dita Aji Pratama +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/. + +import sys +from bottle import Bottle, run +from beaker.middleware import SessionMiddleware + +import handler + +from config import server +from config import directory + +app = Bottle() + +app.merge(handler.app) +app.merge(directory.app) + +app = SessionMiddleware(app, server.session_opts) + +run(app, + host = server.host, + port = server.port, + reloader = server.reloader, + server = server.server, + debug = server.debug +)