🙈 Dead Simple Web Framework 🙉
Overview:
A RESTful Flask framework with MongoDB, Redis, Celery, Slack and Sentry integrations:
Backend:
- Flask [Framework]
- MongoDB [Database]
- Redis [Cache]
- Celery + RabbitMQ [Async Tasks]
- Slack + Sentry [Logging]
Installing:
$ pip install dead-simple-framework
Configuration:
TODO - DOCS
Example Application (demo.py):
from dead_simple_framework import Route, RouteHandler, Application
from dead_simple_framework.handlers import UserRouteHandler, LoginRouteHandler, Permissions, DefaultPermissionsRouteHandler
from dead_simple_framework.database import Indices
from dead_simple_framework.api.errors import API_Error
from dead_simple_framework.api.utils import JsonError
# Method that throws a sample error
def throw(msg): raise API_Error(msg, 400)
# App config for a simple blog application with user accounts
sample_config = {
'routes': {
# Users
'users': Route(
# Route with a built-in handler for creating, updating, fetching and deleting users
# Only authenticated users can perform certain operations.
# Adding a `verifier` to the class will let you allow only a specific user to update
# their data or delete their account.
url = '/api/users',
handler=UserRouteHandler(permissions=Permissions(
PUT='USER', PATCH='USER', GET='USER', DELETE='USER'
)),
# The schema controls what data can be passed to the endpoint
# In this case, a user ObjectId is required and the only property
# supported.
schema={
'GET': {
'type': 'object',
'properties': {
'_id': {'type': 'string'}
},
'required': ['_id']
}
},
# The MongoDB collection where data for this route should be stored
# It is passed to any overloaded method handlers (e.g. a custom GET method)
collection='users'
),
# Authentication
'authentication': Route(
# Route with a built-in handler for authenticating users and issuing a JSON Web Token
url='/api/authenticate',
handler=LoginRouteHandler(),
# It relies on the same collection as the core `users` route
collection='users'
),
# Posts
'posts': Route(
# Route with a builtin generic CRUD handler for creating, updating, fetching and deleting posts
# Only authenticated users can perform certain operations.
url='/api/posts',
handler=DefaultPermissionsRouteHandler(permissions=Permissions(POST=['USER'], PUT=['USER'], PATCH=['USER'], DELETE=['USER'])),
collection='posts'
),
# Sample Error
'error': Route(
# Route that demonstrates built-in error handling
url='/error',
handler=RouteHandler(
# Custom handlers allow a POST request or a GET request to create different errors
POST=lambda request, payload: throw(f'POST - Error from payload {payload}'),
GET=lambda request, payload: JsonError('This is a GET error', code=500),
)
),
},
# Application settings
'settings': {
# JWT Settings determine if the app uses JWT, what the token lifespan will be and more
'jwt_settings': {
'app_use_jwt': True,
'app_jwt_lifespan': 600,
'app_permissions': ['USER', 'ADMIN'],
}
},
# MongoDB indices for each collection used by the application
'indices': Indices({
'users': {
'username': {
'order': -1
},
'password': {
'order': 1,
'compound_with': 'username'
}
},
})
}
if __name__ == '__main__':
Application(sample_config).run()
-
Starts a local server at http://0.0.0.0:5000/
-
Serves CRUD operations for MongoDB users collection
usersat endpoint/api/users -
Issues JWT tokents for created users at endpoint
/api/authenticate -
Serves CRUD operations for MongoDB collection
postsat endpoint/api/posts -
Demos errors at endpoint
/error
Metadata
Release files for dead-simple-framework 1.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dead_simple_framework-1.3.9.tar.gz | 35.8 kB | Without provenance | Details for dead_simple_framework-1.3.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dead_simple_framework-1.3.9-py3-none-any.whl | Python 3 | none | any | Details for dead_simple_framework-1.3.9-py3-none-any.whl |
Total release size: 85.0 kB
Release files / dead_simple_framework-1.3.9.tar.gz
| Download URL | dead_simple_framework-1.3.9.tar.gz |
|---|---|
| Size | 35.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d54afa2407dda1dec9b85aa1b3f3630b639e351b033bc053b70c95362e5bfdbb
|
|
BLAKE2b-256 checksum How to use checksums |
09deeb09a4e2c2e4e56ef44bd4c058b73c8bc53c43e9cdd5dbe4180dc02e295a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/65.4.1 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.9.15
|
Release files / dead_simple_framework-1.3.9-py3-none-any.whl
| Download URL | dead_simple_framework-1.3.9-py3-none-any.whl |
|---|---|
| Size | 49.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ead8c9cd8ee1bb2229dea6698cb0fdc6926f5be732188d54eed68e2fc2227fdd
|
|
BLAKE2b-256 checksum How to use checksums |
4bb061263309cf30042e49cb573a4c23d7f3106ed39cf5ca94d2859b4a34c06d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/65.4.1 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.9.15
|
Security for dead-simple-framework 1.3.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.