Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1017 Bytes

sample2.md

File metadata and controls

50 lines (34 loc) · 1017 Bytes

Web App Server

Application with a template

Create a folder inside extensions folder of webserver and in the created folder create a python file name __init__.py with this content:

#
# An web server module
#

import datetime
from appmodule import AppModule

app = AppModule()

def getApp():
    return app

@app.route("/")
@app.view("index.tpl")
def _():
    """
        Default view
    """
    return dict(title = "Application with a template",
                now = datetime.datetime.now())

Then create a folder next to __init__.py and name it view.

In the view folder create index.tpl with this content:

% include("header.tpl")

<h1>{{title}}</h1>
now = {{now}}

% include("footer.tpl")

The python function used as web method use two decorators: app.route and app.view.

Use admin page to view list of applications, reboot server and to access the link to your application.

Your application is available after server restart.