Specify APIs with a Python dict and run with one line
Project description
🙈 Dead Simple Web Framework 🙉
Overview:
A dead simple framework for web applications:
Backend:
- Python 3.7 [Flask]
- MongoDB
- Celery + RabbitMQ
- TODO: Kafka Hooks
- TODO: Redis Hooks
Installing:
$ pip install dead-simple-framework
Configuration:
TODO
Example Application (demo.py
):
* MongoDB must be running *
$ mongod
$ rabbitmq-server
$ celery -A demo worker -l info
from dead_simple_framework import Application, Task_Manager, Database
sample_config = {
'routes': {
'/demo': {
'name': 'demo',
'methods': ['GET', 'POST', 'DELETE', 'PUT'],
'template': None,
'defaults': None,
'logic': None,
'collection': 'demo'
},
'/': {
'name': 'index',
'methods': ['GET'],
'template': None,
'defaults': None,
'logic': lambda: str(Task_Manager.run_task('add', [5, 8], kwargs={})),
},
'/insert': {
'name': 'insert',
'methods': ['GET', 'POST', 'DELETE', 'PUT'],
'template': None,
'defaults': None,
'logic': None,
'collection': 'insert'
}
},
'tasks': {
'add': {
'logic': lambda x,y: x + y,
'schedule': None,
'timeframe': None,
'args': (2,2)
},
'insert': {
'logic': lambda res: Database(collection='insert').connect().insert_one({'test': 'doc', 'result': res}),
'schedule': {}, # Default - every minute
'timeframe': None,
'depends_on': 'add' # Return value substituted for `res`
}
}
}
app = Application(sample_config)
if __name__ == '__main__':
app.run()
-
Starts a local server at http://0.0.0.0:5000/
-
Serves CRUD operations for MongoDB collection
demo
at endpoint/demo
. -
Runs and returns the result of an asynchronous Celery task at endpoint
/
-
Runs an asynchronous chained value calculation and insert into the
insert
collection (viewable at/insert
)
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
Close
Hashes for dead_simple_framework-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc1342674b1dc9138a6b0e04ebcefdd98808ecf5e64029368c3dcb17f3b9af4d |
|
MD5 | c2a448e8916a0a6e61ab6621c0a4e19e |
|
BLAKE2b-256 | 83b17e5b776efb61f61746466937b101e125396e4b7befc7ca10a69747873bf5 |
Close
Hashes for dead_simple_framework-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5bef19ca67177efea1edf65186aae1c5585085eb20f7736fd17d5a8c5c65dc1 |
|
MD5 | f5f08780060e9546cef4bfab4adc40b3 |
|
BLAKE2b-256 | 95905e237214c4ffbb46d5ca7d2dfbe0c4a02be37ba56f0b8b2dd0dbfa7a81a4 |