Example #1
0
def _register_openapi(app):
    from ursh.schemas import TokenSchema, URLSchema
    with app.app_context():
        spec = APISpec(
            openapi_version='3.0.2',
            title='ursh - URL Shortener',
            version='2.0',
            plugins=(
                FlaskPlugin(),
                MarshmallowPlugin(),
            ),
        )
        spec.components.schema('Token', schema=TokenSchema)
        spec.components.schema('URL', schema=URLSchema)
        app.config['APISPEC_SPEC'] = spec
        apispec = FlaskApiSpec(app)
        apispec.register_existing_resources()
Example #2
0

@app.route("/api/image", methods=["POST"])
@doc(description="Store file", tags=["storage"])
@authorized
def store_image():
    cover_photo = request.files["image"]
    photo_name = cover_photo.filename
    image_url = upload_file(photo_name, cover_photo)
    return jsonify({"image_url": image_url})


@app.route("/api/qr")
def create_qr_code():
    organisation_id = request.args.get("organisation_id")
    location = request.args.get("location")
    location = quote_plus(location)
    url = f"{request.base_url}/dashboard/{organisation_id}?location={location}"
    qrcode_url = f"https://api.qrserver.com/v1/create-qr-code/?size=150x150&data={url}"

    return render_template(
        "code.html",
        qrcode_url=qrcode_url,
    )


docs.register_existing_resources()

if __name__ == "__main__":
    app.run(host="0.0.0.0")
Example #3
0
def register_router_documents(app):
    print('register api documentations')
    spec = FlaskApiSpec(app=app)
    spec.register_existing_resources()