web framework based on Asyncio stack
Project description
The Muffin
The Muffin – A web framework based on Asyncio stack. (early alpha)
Requirements
python >= 3.3
Installation
The Muffin should be installed using pip:
pip install muffin
Usage
See sources of example application.
Run example server:
$ make run
Configuration
Muffin gets configuration options from python files. By default the package tries to load a configuration from config module (config.py).
There are few ways to redifine configuration module:
Set configuration module in your app initialization:
app = muffin.Application('myapp', CONFIG='config.debug')
Set environment variable MUFFIN_CONFIG:
$ MUFFIN_CONFIG=settings_local muffin example.app:app run
Also you can define any options while initializing your application:
app = muffin.Application('myapp', DEBUG=True, ANY_OPTION='Here', ONE_MORE='Yes')
Base application options
Base Muffin options and default values:
# Configuration module 'CONFIG': 'config', # Enable debug mode 'DEBUG': False, # List of enabled plugins 'PLUGINS': ( 'muffin.plugins.manage:ManagePlugin', 'muffin.plugins.jade:JadePlugin', 'muffin.plugins.peewee:PeeweePlugin', 'muffin.plugins.session:SessionPlugin', ), # Setup static files in development 'STATIC_PREFIX': '/static', 'STATIC_ROOT': 'static',
CLI integration
Run in your shell:
$ muffin path.to.your.module:app_object_name --help
Write a custom command
@app.plugins.manage.command def hello_world(option=None, boolean_option=False): """ Command help here. :param option: Option help here """ print('Hello world!')
Templates (Jade)
Use jade.render in your handlers:
@app.view('/') def hello(request): return (yield from app.plugins.jade.render( 'index.jade', user=request.session.get('user', 'anonimous')))
The syntax is:
jade.render(TEMPLATE_NAME, **CUSTOM_CONTEXT)
Add default context provider:
@jade.ctx_provider def my_context(): """ Could be a coroutine. """ return { ... }
Sessions
SQL (Peewee)
Migrations
Create migrations:
$ muffin example.app:app create [NAME]
Run migrations:
$ python example.app:app migrate [NAME]
Testing
Set module path to your Muffin Application in pytest configuration file or use command line option --muffin-app.
Example:
$ py.test -xs --muffin-app example.app:app
Deployment
Use muffin command. By example:
$ muffin example.app:app run --workers=4
See muffin {APP} run --help for more info.
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin/issues
Contributing
Development of The Muffin happens at: https://github.com/klen/muffin
Contributors
klen (Kirill Klenov)
License
Licensed under a MIT license (See LICENSE)
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
File details
Details for the file muffin-0.0.41.tar.gz
.
File metadata
- Download URL: muffin-0.0.41.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d52c89660663181a26d3943b936bcd6b8f4d1bb4e7daaafbb94f14f51032c31 |
|
MD5 | aed73b26be39a0e8095530c28cd71df3 |
|
BLAKE2b-256 | 0028896003098600a762c9d9698c67933c91e97da269a5cb6af0a48d122372b3 |
File details
Details for the file muffin-0.0.41-py2.py3-none-any.whl
.
File metadata
- Download URL: muffin-0.0.41-py2.py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08c59f9db3394ea86b3f0d6b209b80d4aa1dd82e4697286845d1e0fa6a390b9c |
|
MD5 | eefdf91982c9fb06dba3575b5c9279db |
|
BLAKE2b-256 | 41a8bc9072c061dc1fa8e600643f31a7f205b4646f63db68a2d5d33934147888 |