Spanner.py is a micro web framework written in python for human beings.
Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
webspanner
.gitignore
LICENSE
README.md
example.py
example_comet.py
requirements.txt
setup.py

README.md

Web Spanner

Spanner is a micro web framework written in python for human beings.

It's inspired by Flask & express.js

How to use it

Installation

pip install webspanner

Spanner is very easy to use.

Here is an example

from webspanner import Spanner

app = Spanner()

@app.route('/')
def index(req, res):
  res.write("Hello world")

The method will be decorated to be a coroutine automatically, so you do not need to decorate the function with @asyncio.coroutine

What's more?

Spanner is very easy to extend.

Middlewares

app = spanner.Spanner()

@app.route("/")
def index(req, res):
  res.write("Hello world!\n")

@app.use
def mid(req, res, handle):
  early = time.time()
  yield from handle()
  late = time.time()
  info = "<br>This connection use {:.5f} seconds".format(late - early)
  res.write(info)

The method will be decorated to be a coroutine automatically, so you do not need to decorate the function with @asyncio.coroutine

The code will export

Hello world!
This connection use 0.00000000 seconds

Sub-app(Not Finish yet)

subapp = Spanner()
app.mount('/sub/', subapp)

Required

  • Python 3.4+ (asyncio)
  • routes

Note

  • 0.1.0: Release! Fix error handles Bugs.