A library for building web applications
Reason this release was yanked:
missing a module
Project description
Glass is a mini WSGI routing library for building web applications. It comes with bultin template engine. It is micro-framework because it comes with limited tools for web development. But it is extensible.
Glass comes with builtin development server.
Installation
Install from pypi;
$ pip istall glass-web
or upgrade to latest release ;
$ pi install --upgrade glass-web
or clone from github;
$ git clone https://github.com/horlarwumhe/glass.git
$ cd glass
$ pip install -r requirements.txt
$ python setup.py install
Example
from glass import GlassApp
app = GlassApp()
@app.route('/')
def home():
return 'Hello, welcome.'
@app.route('/greet/<name>')
def greet(name):
return 'Hello {}'.format(name)
app.run()
#app.run(host='127.0.0.1',port=8000,debug=True,auto_reload=True)
Using Template
Glass template syntax is very similar to django template.
# index.html
<html>
<title> {% block title %} Blog {% endblock %}</title>
<body>
{% block content %}
{% for post in posts %}
<h3> {{post.title}} </h3>
Author: <b> {{post.author}}
<a href='{{post.url}}'> read more </a>
{% endfor %}
{% endblock %}
</body>
from glass import GlassApp
from glass import render_template,render_string
from glass import request,redirect
app = GlassApp()
@app.route('/')
def home():
posts = get_all_posts()
return render_template('index.html',posts=posts)
@app.route('/greet/<name>')
def greet(name):
template = '''
Hello {{name}}, welcome to {{request.host}}
'''
return render_string(template,name=name)
@app.route('/login',methods=["GET",'POST'])
def login():
if request.method == 'POST':
name = request.post.get('username')
password = request.post.get('password')
do_login(name,password)
return redirect('/')
else:
return render_template('login.html')
app.run()
Documentation
Documentation is available on glass site. It is also available on readthedocs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
glass-web-0.0.3.tar.gz
(35.5 kB
view hashes)
Built Distribution
glass_web-0.0.3-py3-none-any.whl
(39.1 kB
view hashes)
Close
Hashes for glass_web-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48f51471a24476465e034533d2349852a5eb72533466f8e04ecb2f97ed74901b |
|
MD5 | 00a388973f225d945a44e778893d5819 |
|
BLAKE2b-256 | 212852b72af8548db87623f0fae965f4895e1de44c746b6f42c141f8fd9db257 |