Skip to main content

Swinf is a simple micro-framework for small web application and has no dependencies other than the Python Standard Liberaty.

Project description

Swinf is a simple micro-framework for small web application and has no dependencies other than the Python Standard Liberaty.

It offers a built-in HTTP Server, and a simple route binding mechanism.


run command : startproject newproject and swinf will create a project directory.

Inside current project directory, there are a and three subdirectories:


containing controllers.


containing view template files.


    static/: contains static files

    static/images: images here

    static/style: css files here

    static/script: js files here

    static/files: other static files here


you can put your database controlling code here.

You can add some controllers in controller directory and run, and it will work.


Currently, swinf have a simple template engine called SimpleTemplate.

the tpl syntax follows below

<!-- in a tpl file -->

# multiline code

def bold_wrapper(txt):
    return "<b>" + txt + "</b>"

%% # sigleline code
%% if name:
<h1> hello {{name}}!</h1>
%% else:
<h1> Hello World!</h1>
%% endif

%% for i in range(100):
    <li>no: {{i}}</li>
%% endfor

To use the template, you can use code like below:

from swinf.template import template
# pass tpl source
html = template("<h1>hello {{name}}", name='world')

# pass a tpl file
html = template(path='index.tpl', name='world')


In swinf, there is no config file, instead, there are two simple route-config ways:

  • A like route binding mechanism
from swinf.swinf import run
from swinf.selector import route

# a simple controller
def hello(name):
    return '<h1>Hello %s!</h1>' % name.title()

run(host='localhost', port=8080)
  • Much simpler route binding mechanism
from swinf.selector import handler

# --------- your code here -----------

def hello():
    return '<h1>Hello</h1>'

def world():
    return '<h1>World</h1>'

This will will automatically bind route /module1/hello to handler controller.module1.hello and /module1/world to handler

You don’t have to add routes manully.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for swinf, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size swinf-0.0.5.tar.gz (29.1 kB) File type Egg Python version 2.7 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page