معرفی شرکت ها


Flask-Hashids-0.2.2


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Hashids integration for Flask applications.
ویژگی مقدار
سیستم عامل OS Independent
نام فایل Flask-Hashids-0.2.2
نام Flask-Hashids
نسخه کتابخانه 0.2.2
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Patrick Jentsch
ایمیل نویسنده patrickjentsch@gmx.net
آدرس صفحه اصلی https://github.com/Pevtrick/Flask-Hashids
آدرس اینترنتی https://pypi.org/project/Flask-Hashids/
مجوز -
# Flask-Hashids Hashids integration for Flask applications, it is based on the [Hashid](https://github.com/davidaurelio/hashids-python) package available on [PyPi](https://pypi.org/project/hashids/). With this extension you can conveniently use integer ids for your application logic or database tables and hash them before exposing it in URLs or JSON data. ## Installation The latest stable version [is available on PyPI](https://pypi.org/project/Flask-Hashids/). Either add `Flask-Hashids` to your `requirements.txt` file or install with pip: ``` pip install Flask-Hashids ``` ## Configuration Flask-Hashids is configured through the standard Flask config API. These are the available options: - **HASHIDS_ALPHABET**: Read more about that in [Hashids documentation](https://github.com/davidaurelio/hashids-python#using-a-custom-alphabet) - **HASHIDS_MIN_LENGTH**: Read more about that in [Hashids documentation](https://github.com/davidaurelio/hashids-python#controlling-hash-length) - **SECRET_KEY**: Used as the salt, read more in [Hashids documentation](https://github.com/davidaurelio/hashids-python#using-a-custom-salt) ## Examples You can find more detailed examples on how to use Flask-Hashids in the examples directory. ```python from flask import Flask, jsonify, url_for from flask_hashids import HashidMixin, Hashids from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SECRET_KEY'] = 'secret!' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' db = SQLAlchemy(app) hashids = Hashids(app) # The HashidMixin class adds the hashid property which will compute a hashid # based on the existing id attribute of the instance. # NOTE: The id attribute must be an int class User(HashidMixin, db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(64), nullable=False) @property def url(self): # The HashidConverter encodes the given id to a hashid in the URL return url_for('user', user_id=self.id) def to_json(self): return {'id': self.hashid, 'name': self.name, 'url': self.url} @app.before_first_request def database_setup(): db.create_all() john = User(name='John') db.session.add(john) jane = User(name='Jane') db.session.add(jane) db.session.commit() @app.route('/users') def users(): return [user.to_json() for user in User.query.all()], 200 @app.route('/users/<hashid:user_id>') def user(user_id: int): # The HashidConverter decodes the given hashid to an int user = User.query.get(user_id) if user is None: return jsonify('User not found'), 404 return user.to_json(), 200 def main(): # You can encode and decode hashids manually id = 123 encoded_id = hashids.encode(id) decoded_id = hashids.decode(encoded_id) app.run() if __name__ == '__main__': main() ``` ## Resources - https://hashids.org/python/


نیازمندی

مقدار نام
- Flask
>=1.0.2 Hashids


زبان مورد نیاز

مقدار نام
>=3.5 Python


نحوه نصب


نصب پکیج whl Flask-Hashids-0.2.2:

    pip install Flask-Hashids-0.2.2.whl


نصب پکیج tar.gz Flask-Hashids-0.2.2:

    pip install Flask-Hashids-0.2.2.tar.gz