全栈的 Python Web 框架 Python weppy

码农软件 · 软件分类 · Web框架 · 2019-03-25 15:59:20

软件介绍

weppy 是一个全栈的 Python Web 框架,weppy 非常灵巧,易于理解学习和使用。兼容 Python 2.7, 3.3, 3.4, 3.5 和 3.6.

示例代码:

from weppy import App, request, response
from weppy.orm import Database, Model, Field
from weppy.tools import service, requires

class Task(Model):
    name = Field('string')
    is_completed = Field('bool', default=False)

app = App(__name__)
app.config.db.uri = "postgres://user:password@localhost/foo"
db = Database(app)
db.define_models(Task)
app.pipeline = [db.pipe]

def is_authenticated():
    return request.headers["Api-Key"] == "foobar"

def not_authorized():
    response.status = 401
    return {'error': 'not authorized'}

@app.route(methods='get')
@service.json
@requires(is_authenticated, otherwise=not_authorized)
def todo():
    page = request.query_params.page or 1
    tasks = Task.where(
        lambda t: t.is_completed == False
    ).select(paginate=(page, 20))
    return {'tasks': tasks}

weppy 可以让你直接用 Python 编写模板:

{{extend 'layout.html'}}

<div class="post-list">
{{for post in posts:}}
    <div class="post">
        <h2>{{=post.title}}</h2>
    </div>
{{pass}}
{{if not posts:}}
    <div>
        <em>No posts here so far.</em>
    </div>
{{pass}}
</div>













本文地址:https://codercto.com/soft/d/2131.html

仿生智能计算

仿生智能计算

科学出版社 / 2011-1 / 50.00元

《仿生智能计算》系统、深入地介绍了仿生智能计算的起源、原理、模型、理论及其应用,力图概括国内外的最新研究进展。全书共分12章,主要包括仿生智能计算的思想起源、研究现状及机制原理,仿生智能计算的数学基础;蚁群算法、微粒群算法、人工蜂群算法、微分进化算法、Memetic算法、文化算法、人工免疫算法、DNA计算的原理、模型、理论和典型应用,以及仿生硬件、仿生智能计算研究前沿与展望。附录给出了各章算法的程......一起来看看 《仿生智能计算》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具