Skip to main content

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.

Metadata

Release files for glass-web 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glass-web 0.0.7
File Size Uploaded Provenance Actions
glass-web-0.0.7.tar.gz 37.0 kB Without provenance Details for glass-web-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for glass-web 0.0.7
File Interpreter ABI Platform Actions
glass_web-0.0.7-py3-none-any.whl Python 3 none any Details for glass_web-0.0.7-py3-none-any.whl

Total release size: 78.0 kB

Release files / glass-web-0.0.7.tar.gz

Download URL glass-web-0.0.7.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5ccbb99da80fccdc2cfc39a9fe0cf9523a99c1aeb4dc137dee0343bf8a2f1711
BLAKE2b-256 checksum
How to use checksums
a023eadac5e74e4583d989703f38a6c83fb1d63c98ea4977f4ca412fb1c0a8dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release files / glass_web-0.0.7-py3-none-any.whl

Download URL glass_web-0.0.7-py3-none-any.whl
Size 41.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66fb5e9f538e498dd8397d92846796002f32bd36b113d43eb7ac7c1d2bc756ab
BLAKE2b-256 checksum
How to use checksums
886246c06a63240ab18e8b79898b17e6cb62ed60d6e589f8d0654e7b1e0ddad1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Security for glass-web 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page