Skip to main content

BunnyPy

a Lightweight Python Web Framework

BunnyPy

PyPI Downloads License

English | 中文

Installation

pip install bunnypy

Simple Usage

a HelloWord Application

from bunnypy import Bunny

app = Bunny()

@app.controller
class IndexController:
    def ac_index(self):
        return 'Hello Bunny'

if __name__ == '__main__':
    app.run()

Data Model

from bunnypy import Bunny
import sqlite3

# ------------------------------------------------------------
# Config database using SQLite3

db = Bunny.SQLiteDatabase(sqlite3.connect('test.db'), 'tp_')
app = Bunny(database=db)

# ------------------------------------------------------------
# Declare a Model Class


@app.data
class Message:
    __pk__ = ['id']
    __ai__ = 'id'
    id = 'integer not null'
    msg = 'text not null'

    def __init__(self, msg=None):
        self.msg = msg


# ------------------------------------------------------------
# Create a table

Message.create() # create a table named "tp_message"

# ------------------------------------------------------------
# Insert Data

Message(msg="New Message").insert() # add a new row into table "tp_message"

# ------------------------------------------------------------
# Chained-call style query

# get one row where msg equals "Test"
Message.where(" msg = ? ",["Test"]).get(['id','msg'])

# get 10 rows of data starting at position 0 and sort by id in reverse order
size = 10
start = 0
Message.where().order(' id desc ').limit(size,start).get_all(['id','msg'])

Template

temp.html in template dir

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Template</title>
</head>
<body>
Output: {{ msg }}
</body>
</html>

Python code

from bunnypy import Bunny

app = Bunny()

@app.controller
class IndexController:
    def ac_index(self):
        return app.render('temp.html',{"msg":"Hello World"})


if __name__ == '__main__':
    app.run()

Metadata

Release files for BunnyPy 0.3.3

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

Source distribution (sdist)

Source distribution for BunnyPy 0.3.3
File Size Uploaded
bunnypy-0.3.3.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for BunnyPy 0.3.3
File Interpreter ABI Platform
BunnyPy-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / bunnypy-0.3.3.tar.gz

Download URL bunnypy-0.3.3.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
683335f3b8a024c9dcdd8a381a8e470029048c9d7d409404e7101e983bd8fb58
BLAKE2b-256 checksum
How to use checksums
cf6032e6a66de57c064c69ea620043006c1dd0198f90be5f0c4194ef22f2cdfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / BunnyPy-0.3.3-py3-none-any.whl

Download URL BunnyPy-0.3.3-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf753f73746a8a8a59cd64efed1b4c4017b601d4efe392ed1b29659f6b22a895
BLAKE2b-256 checksum
How to use checksums
b91ab8add8848b154ee5e8786701ed370b5e391e66e1f8ed1150de1392bed1a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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