https://github.com/subsetpark/logl
a toy web framework for educational purposes.
https://github.com/subsetpark/logl
Last synced: about 1 year ago
JSON representation
a toy web framework for educational purposes.
- Host: GitHub
- URL: https://github.com/subsetpark/logl
- Owner: subsetpark
- Created: 2014-02-19T23:37:37.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-16T13:40:59.000Z (about 12 years ago)
- Last Synced: 2025-04-06T13:49:54.436Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 249 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
logl (לאָגל)
======
Logl is a framework modelled on the well-known framework for Python, [Flask][]. It is a WSGI application that implements much of what you'd expect from a simple framework:
- routes
- db access
- html templating
- GET and POST parsing
[flask]: flask.pocoo.org
## Usage
To build a web application with logl, simply start a new project and import the logl module. Logl has a structure very similar to Flask. At the top of your application you should instantiate a new application object:
```python
from logl import Logl, Response
app = Logl()
```
This application will be your main point of interaction for your web app. Then proceed to define functions for the endpoints of your app, using a decorator to denote the url.
```python
@app.add_route('/')
def index():
"""
Display the requested path.
"""
app.add_replace('query', app.request.query)
response = app.response(template="index.html")
return response
```
In the above example, we are also passing a variable to the application's "context", which is where it stores data for the templating engine to access.
```
{{extends base.html}}
{{block name}}
If page
{{endblock}}
{{block content}}
This page demonstrates conditionals.
{{if first}}
This is a basic if.
{{endif}}
{{if second}}
This is an if with an else.
{{else}}
This is an else.
{{endif}}
{{endblock}}
```
Logl's templating engine supports basic jinja-style features including conditionals, block extension, and variable substitution.