New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

miniflask

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miniflask

Small research-oriented hook-based plugin engine.

  • 5.1.2
  • PyPI
  • Socket score

Maintainers
1

MiniFlask

python-3 badge python-3 badge CI build status

Miniflask is a small research-oriented plugin-engine for python.

A long time ago in a galaxy full of plugin-engines ...

Quick Start

For a quick look into miniflask, just install it using

pip install miniflask

Read the Documentation

Short Example

Module Definition
Let's start a new project first by creating a new directory:

> ls
main.py
modules/
    module1/__init__.py
    module2/__init__.py
    module1/__init__.py

Let's define a simple module, modules/module1/__init__.py:

def main(state, event):
    print("main event called by module1")

def register(mf):
    mf.register_event('main', main, unique=False)

Let's define another module, modules/module2/__init__.py:

def main(state, event):
    print("main event called by module2")
    print("it uses a variable var:", state["var"])

def register(mf):
    mf.register_defaults({
        "var": 42
    })
    mf.register_event('main', main, unique=False)

Our main.py looks like this:

import miniflask

# initialize miniflask
mf = miniflask.init(".modules")
mf.run()

Usage:
Now, we can use our program in the following ways:

> python main.py
There is nothing to do.
> python main.py module1
main event called by module1
> python main.py module2,module1
main event called by module2
it uses a variable var: 42
main event called by module1
> python main.py module2,module1 --module2.var 9001
main event called by module2
it uses a variable var: 9001
main event called by module1

Contributing

  1. Fork it!
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

License

License: MIT - See LICENSE for details.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc