#!/usr/bin/env python3

from cuchulu.libraries.mtemplates import PTemplate, env_theme
from cuchulu.libraries.urls import make_url
from cuchulu.wsgiapp import app
from settings import config
from cuchulu.modules.welcome import welcome_app
from bottle import request

#t=ptemplate(__file__)
env=env_theme(__file__)

t=PTemplate(env)

@welcome_app.route('/welcome')
def home():
    
    return t.render_template('welcome.html', title="Welcome to Cuchulu!!!", content="The simple web framework writed in Python3!!!")

@welcome_app.route('/welcome/<id:int>')
def page(id):
    return t.render_template('index.html', title="A simple example of a page", id=id, value=request.query.value)

@welcome_app.route('/welcome/test/<int_id:int>')
def test(int_id):
    
    return make_url(f'welcome/test/{int_id}', {'ohmygod': 'This is gooood', 'shutup':'Shut up!!'})

if config.default_module=="welcome":

    home = app.route("/")(home)
