flask-restx
flask-restx copied to clipboard
How to user restx with blueprint
In the restx docs it says that can be used with flask blueprint, but I can't reproduce
How to do this, without rewriting the flasks endpoints?
Code
from flask import Flask, Blueprint
from flask_restx import Api
import logging
logger = logging.getLogger(__name__)
app = Flask(__name__)
def initialize_app(app):
app.config['RESTX_VALIDATE'] = True
app.register_blueprint(get_api(logger, app), url_prefix='/open')
return app
def get_api(logger, app):
open_bp = Blueprint('open', __name__)
@open_bp.route('/hello')
def hello():
return 'Hello World'
api = Api(
open_bp,
version='0.1',
title='webserver hello',
description='',
doc='/doc/',
url_scheme='http'
)
#api.init_app(open_bp)
return open_bp
def run():
return initialize_app(app)
Expected Behavior
I would like to use a api made on flask blueprint into restx
Environment
- Python version 3.9
- Flask version 2.3.3
- Werkzeug 3.0.1
- Flask-RESTX version 1.1.0
- Other installed Flask extensions