bottle.py suite with CORS, SQL, REST, and JWT
Project description
Bottle Suite
Bottle.py suite with CORS, SQL, REST, and JWT
Installation
python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ bottle-suite --upgrade
Usage
CLI
Create Project
$ bottle-suite-create
Enter project name. <bottle-suite-project>:
Create a SQLite database? [y/N]:
Attach an SQL database? [y/N]:
Created project bottle-suite-project
cd bottle-suite-project
bottle-suite -d -r
Run
$ cd bottle-suite-project
$ bottle-suite -d -r
View dashboard @ http://localhost:8000/dashboard
Bottle v0.13-dev server starting up (using WSGIRefServer(dashboard=True))...
Listening on http://localhost:8000/
Hit Ctrl-C to quit.
Options
usage: bottle-suite [-h] [--port PORT] [--host HOST] [--jwt JWT_KEY] [--sqlite [PATH]] [--dbhost DBHOST] [--dbname DBNAME] [--dbuser DBUSER] [--dbpass DBPASS] [--cors CORS] [-r] [-d]
optional arguments:
-h, --help show this help message and exit
--port PORT Port to listen on
--host HOST Host to listen on
--jwt JWT_KEY JWT key
--sqlite [PATH] Path to SQLite database (default: bottle-suite/src/scripts/tmp.db)
--dbhost DBHOST SQL database host
--dbname DBNAME SQL database name
--dbuser DBUSER SQL database username
--dbpass DBPASS SQL database password
--cors CORS Enable CORS
-r Automatic reloading
-d Enable dashboard
Import
app.py
from bottle_suite import BottleSuite
app = BottleSuite()
app.run(reloader=True)
Resources
Resource Folder
Bottle Suite will attempt to automatically find Resources objects in a resource folder in the working directory and create endpoints for them. By default it will look for a folder named "resources". All ".py" files in the folder will be scanned for Resource objects.
Example Project Structure
├── src
│ ├── resources
│ │ ├── __init__.py
│ │ ├── resource_a.py
| | ├── resource_b.py
│ ├── app.py
Resource Objects
resource_a.py
from bottle_suite import Resource
class ResourceA(Resource):
def options(self):
pass
def get(self):
return {}
def post(self):
pass
def put(self):
pass
def patch(self):
pass
def delete(self):
pass
Adding Endpoints for Resources
Bottle Suite has a Bottle REST object. Resources can be added by accessing the Bottle REST object and calling addResource().
app.py
from resources.resource_a import ResourceA
from bottle_suite import BottleSuite
app = BottleSuite()
app.rest.addResource(ResourceA, "/resource_a")
app.run(reloader=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bottle_suite-0.0.17.tar.gz.
File metadata
- Download URL: bottle_suite-0.0.17.tar.gz
- Upload date:
- Size: 342.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9645c4e2230399c1f2650fd5847ef5852ac8f79b1c8a6c5f79f3e6e51e1c524b
|
|
| MD5 |
215a948fb689c2498e8e4dbf7823cd5d
|
|
| BLAKE2b-256 |
b960d2779ff57d37e8ec1da93b462125edfa22cccdd885fbefe29a7dbe540132
|
File details
Details for the file bottle_suite-0.0.17-py3-none-any.whl.
File metadata
- Download URL: bottle_suite-0.0.17-py3-none-any.whl
- Upload date:
- Size: 351.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
784b04888f7f7c384ceb018c7c6ff91455bd0bdfba8115ba50dcd0ee588abb73
|
|
| MD5 |
c34532a8f055cfb6bcd2008a72430350
|
|
| BLAKE2b-256 |
4498e4ca0cf02e63575690511ad12c7ae6402cbb304dabe0369337ae8dbc344f
|