Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Shell2HTTP class to inherit from Flask.Blueprint #7

Open
eshaan7 opened this issue Nov 1, 2020 · 0 comments · May be fixed by #28
Open

Convert Shell2HTTP class to inherit from Flask.Blueprint #7

eshaan7 opened this issue Nov 1, 2020 · 0 comments · May be fixed by #28
Assignees
Labels
enhancement New feature or request

Comments

@eshaan7
Copy link
Owner

eshaan7 commented Nov 1, 2020

Currently, flask-shell2http works just like any other flask extension; you create an object from a class to which you pass the flask application instance. We could follow a different approach making it solely available as a pluggable Flask.Blueprint.

Some initial ideas:

  • The Shell2HTTP class could derive from the Flask.Blueprint class; that way we can drop the init_app method, the register_command can be a wrapper over the Flask.Blueprint.add_url_rule method (it already is, but it works on app.add_url_rule). Then, the enduser would do something like,
from flask_shell2http import Shell2HTTP
# default blueprint instantiation
shell2http_bp = Shell2HTTP('awesome', __name__, url_prefix='/commands')
# extra method by flask-shell2http
shell2http_bp.register_command(endpoint="echo", command_name="echo", ...)

and then in the application factory,

app = Flask(__name__)
app.register_blueprint(shell2http_bp)

This would open doors for many other features since Flask.Flask and Flask.Blueprint derive from the same abstract base class and flask blueprints are very powerful.

@eshaan7 eshaan7 added the enhancement New feature or request label Nov 10, 2020
@eshaan7 eshaan7 linked a pull request Sep 22, 2021 that will close this issue
4 tasks
@eshaan7 eshaan7 modified the milestone: v2.0.0 Sep 22, 2021
@eshaan7 eshaan7 self-assigned this Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant