-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi! I decided to build an application using the Flask-Pluginengine architecture. I'm trying to create it as a RESTful service that feeds an Angular frontend. To build it I use the Flask Restful extension library to organize the code.
Currently I'm using this hacky version of my code to work with Plugins, but I'd like to know if there's a more proper way to integrate Flask-Restful and Flask-PluginEngine. Thanks for this amazing work!
App structure:
MainApp.py
plugins
-----test
---------setup.py
---------TestPlug.py
MainApp.py
#Import Flask library and dependencies.
from flask import Flask
#Import Flask Restful.
from flask_restful import Resource, Api, reqparse
#Import library to allow Plugin modules.
from flask_pluginengine import PluginFlask, PluginEngine
#Define a new flask App.
app = PluginFlask(__name__)
#Transform the App into a Restful instance.
api = Api(app)
#Initialize Flask plugin.
app.config['PLUGINENGINE_NAMESPACE'] = 'plugins'
app.config['PLUGINENGINE_PLUGINS'] = ['testplug']
#Load the Plugins available.
plugin_engine = PluginEngine(app=app)
plugin_engine.load_plugins(app)
active_plugins = plugin_engine.get_active_plugins(app=app).values()
print(active_plugins)
PluginCode called TestPlug.py
from flask_pluginengine import Plugin
from flask_app import Resource, api
class TestPlugin(Plugin):
def get(self):
print("It works!!!")
class TestPluginCode(Resource):
def get(self):
return "It works!!!"
api.add_resource(TestPluginCode, "/testplug")
Setup file for the plugin called setup.py
from setuptools import setup
setup(
name='testPlugin',
version='0.0.1',
#Module that you'll be using.
py_modules=['testplug'],
entry_points={'plugins': {'testplug=TestPlug:TestPlugin'}}
)
Metadata
Metadata
Assignees
Labels
No labels