Repository navigation
GettingStarted
##Installation
Download the project ZIP file, unpack it and in directory trunk run python setup.py install
To test that everything works, go to the subdirectory www and run python server.py
This will start the built-in server on port 80. If you want another port, edit server.py and change the last line
Karrigell.run(apps=[MyApp])to
Karrigell.run(apps=[MyApp], port=8000)Once the server is started, type http://localhost in a browser (or http://localhost:8000). If all went well, a home page is displayed
Click on the link "Login". Since it's the first connection, no user has already been identified, so you should enter a login and password for the administrator
When this is done, the home page prints your login, and there is a link to a users management script
##Introduction to scripts
Karrigell scripts are pure Python scripts, run in a namespace prepared by the framework. Requests are managed by functions defined in the scripts : the url http://host/path/foo.py/bar is managed by the function bar of script foo.py
The matching between host/path and the directory where the script stands is defined by the application settings (see ApplicationSettings)
An application with several pages can be defined in a single Python script :
head = HEAD(TITLE("Cities"))
def index():
form = FORM(action="show")
form <= INPUT(name="city")
form <= INPUT(Type="submit",value="Ok")
return HTML(head+BODY(form))
def show(city):
return HTML(head+BODY(city))In this simple example, the function index() returns an HTML page with a form to be filled by the user. The attribute action of this form tells the framework to target the function show(), and passes the argument city to this function. Here, the function just echoes the value
The names in uppercase letters (HEAD, FORM, etc) are in the execution namespace : they match all the valid HTML tags and are used to generate HTML code. See [WriteHtml HTML Tags] for more information
The names defined at the script level are available in all functions : here, the name head can be used in both functions to return the same HTML header with the page title