For templating. Including: launcher and directory config

This commit is contained in:
Dita Aji Pratama 2024-06-17 12:34:19 +07:00
parent 24a5c602a3
commit d4d12d920d
3 changed files with 66 additions and 0 deletions

19
app/config/directory.py Normal file
View File

@ -0,0 +1,19 @@
from bottle import Bottle, get, static_file
page = {
'public' :'pages/public'
}
app = Bottle()
# Default staticdir
@app.get("/css/<filepath:re:.*\.(css|sass|css.map)>")
def static(filepath):
return static_file(filepath, root="./static/css")
# Template staticdir: plain
@app.get("/templates/plain/css/<filepath:re:.*\.(css|sass|css.map)>")
def static(filepath):
return static_file(filepath, root="./templates/plain/static/css")

17
app/core/html.py Normal file
View File

@ -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

30
app/costa.py Normal file
View File

@ -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
)