Flask-ULID

I have just published Flask-ULID as my first Flask extension.

If you import it, you can use ULID for paths in your Flask app like below:

from flask import Flask
from flask_ulid import FlaskULID

app = Flask(__name__)
FlaskULID(app)

@app.route('/article/<ulid:article_id>')
def article(article_id):
    return '{} is valid ulid'.format(article_id)

If a client accesses to the app with valid ULID like "01D1XRWCR4W1Z38722K3SC3PNH", article() function receives article_id which is an instance of ULID. Like any other routing rules on Flask, accesses with invalid value receives 404 errors.

Please try it and feedbacks are welcome.

この記事が気に入ったらサポートをしてみませんか?