Saravanan666/pypi-org huggingface dataset:
Package: fastapi-throttling
FastAPI Throttling MiddlewareFastAPI Throttling Middleware is a rate-limiting middleware for the FastAPI web framework. It uses a Redis server for request tracking and allows you to throttle incoming requests based on IP address and access token.
FeaturesIP-based throttling: Limit requests based on client's IP address.
Token-based throttling: Limit requests based on user access token.
Redis integration: Uses Redis as a fast, in-memory data store to track request count.
Configurable rate limits: Set your own request limit and time window.InstallationFirst, ensure you have a running Redis server.Next, install the middleware library.pipinstallfastapi-throttlingUsageHere's a basic example of how to use the middleware:fromfastapiimportFastAPI,Request,HTTPExceptionfromfastapi_throttlingimportThrottlingMiddlewareapp=FastAPI()app.add_middleware(ThrottlingMiddleware,limit=100,window=60)In this example, the middleware will limit to 100 requests per 60 seconds, either by IP or by user token.LicenseGNU LESSER GENERAL PUBLIC LICENSE Version 2.1
Package: fastapi-toolbar
Welcome to FastAPI-ToolbarOriginal work:https://github.com/mongkok/fastapi-debug-toolbarInstallationpipinstallfastapi-toolbarQuickstartAddDebugToolbarMiddlewaremiddleware to your FastAPI application:fromdebug_toolbar.middlewareimportDebugToolbarMiddlewarefromfastapiimportFastAPIapp=FastAPI(debug=True)app.add_middleware(DebugToolbarMiddleware)SQLAlchemyPlease make sure to use the"Dependency Injection"system as described in theFastAPI docsand add theSQLAlchemyPanelto your panel list:If you're using a database session generator (usingyield), please add the full python path of your generators
on thesession_generatorsoptions, when adding the middleware:# database.pyfromtypingimportGeneratorfromsqlalchemyimportcreate_enginefromsqlalchemy.ext.declarativeimportdeclarative_basefromsqlalchemy.ormimportsessionmakerengine=create_engine("sqlite://",connect_args={"check_same_thread":False})SessionLocal=sessionmaker(bind=engine)Base=declarative_base()Base.metadata.create_all(bind=engine)defget_db()->Generator:db=SessionLocal()try:yielddbfinally:db.close()# sqlite will drop tables in memoryBase.metadata.create_all(bind=engine)# create tables again# app.pyfromfastapiimportFastAPIfromdebug_toolbar.middlewareimportDebugToolbarMiddlewareapp=FastAPI()app.add_middleware(DebugToolbarMiddleware,panels=["debug_toolbar.panels.sqlalchemy.SQLAlchemyPanel"],session_generators=["database:get_db"]# Add the full python path of your session generators)Tortoise ORMAdd theTortoisePanelto your panel list:fromfastapiimportFastAPIfromdebug_toolbar.middlewareimportDebugToolbarMiddlewareapp=FastAPI()app.add_middleware(DebugToolbarMiddleware,panels=["debug_toolbar.panels.tortoise.TortoisePanel"],)
Package: fastapi-to-openapi
fastapi_to_openapifastapiのopenAPIをyamlまたはjsonで保存する使い方poetryrunfastapi_to_openapiOptions:-i,--input_fileTEXTinputfileincludefastapiAPP-f,--funcTEXTfastAPIapp-o,--output_fileTEXToutputfilename-t,--file_type[yaml|json]outputfiletype.yamlorjson--helpShowthismessageandexit.
Package: fastapi-tortoise-crud
fastapi-admin项目默认会安装fastapi_paginationfastapitortoise-orm目前只支持pydantic-v2简单示例main.pyfromfastapiimportFastAPIfromtortoise.contrib.fastapiimportregister_tortoisefromuvicornimportrunfrommodelsimportUserfromfastapi_tortoise_crud.crudimportModelCruduser=ModelCrud(User,schema_filters=User.schema_filters(include=('username',))).register_crud()app=FastAPI()app.include_router(user,prefix='/user',tags=['用户管理'])@app.get("/")asyncdefroot():return{"message":"Hello World"}register_tortoise(app,db_url="sqlite://:memory:",modules={"models":["models"]},generate_schemas=True,add_exception_handlers=True,)if__name__=='__main__':run("main:app",port=2103,reload=True)models.pyfromfastapi_tortoise_crud.modelimportBaseModelfromtortoiseimportfieldsclassUser(BaseModel):username=fields.CharField(64)password=fields.CharField(32)nickname=fields.CharField(32,null=True,default='游客')路由
Package: fastapi-tortoise-pagination
这个是一个基于FastApi+tortoise-orm的查询集分页器主要通过对QuerySet进行分页排序等进行操作，再对即将响应的数据进行序列化，相比较一些先序列化再分页的分页器，这个会更轻简快速。一、介绍
该分页器主要分为三个块：Params、PagePydantic和paginationParams
前端传的参数，包括page(页数)、size(页面大小)和order_by(排序字段，选传)PagePydantictotal: int          # 查询总数
    page: int
    size: int
    total_pages: int    # 总页数
    next: str           # 下页url
    previous: str       # 上页url响应模型，即返回给前端的数据模型
2. pagination
分页操作，将查询集QuerySet进行分页或者排序等操作，然后在根据用户自定义的Pydantic进行序列化，最后返回分页后的数据二、快速开始：install(安装)pip install fastapi-tortoise-pagination使用class ForumArticle(models.Model):
        """论坛文章"""
        id = fields.IntField(pk=True)
        user = fields.ForeignKeyField("cp_model.User", on_delete=fields.CASCADE)
        title = fields.CharField(max_length=32, default='', null=True)  # 文章标题
        content = fields.TextField(default='', null=True, blank=True)  # 文章正文

    class ForumArticleSchema(
    pydantic_model_creator(ForumArticle,
                           name="ForumArticleSchema",
                           exclude=())
    ):
    pass


    class TestViewSet(BaseViewSet):
        model = ForumArticle
        schema = ForumArticleSchema
        pk_type = str
        views = {
        }

    @Action.get("/list",  response_model=PagePydantic[ForumArticleSchema],description="分页获取帖子列表")  #
    async def list(self, params: Params = Depends()):
        query_set = ForumArticle.filter(is_delete=0)
        return await pagination(pydantic_model=ForumArticleSchema, query_set=query_set, params=params)
Package: fastapi-tryton
FastAPI-TrytonAdds Tryton support to FastAPI application.By default transactions are readonly except for PUT, POST, DELETE and PATCH
request methods.
It provides also 2 routing convertersrecordandrecords.Setting theconfigure_jinjaflag adds the following filters on jinja
templates:numberformat,dateformat,currencyformatandtimedeltaformat. The filters apply the same formatting as Tryton reports.NutshellTODO: Add examples of use, and docs, all collaboration is welcome!,
but for now you can see test_api.py file where there is examples ;)
Package: fastapi-tusd
FastAPI Server for Tus ProtocolA file upload server of the tus resumable upload protocol is implemented on FastAPI framework.Getting startedImportTusRouterto your application,fromfastapiimportFastAPIfromfastapi_tusdimportTusRouterapp=FastAPI()app.include_router(TusRouter(store_dir="./files",location="/files"),prefix="/files")Then the tus upload endpoints will be served athttp://127.0.0.1:8000/files, more information is available athttp://127.0.0.1:8000/docsExamplesThere a simple example with web file upload client supporting forTusprotocol, thanks toUppy!Enter theexample/folder, run(pip install uvicornif nouvicorn!)uvicornapp_tusd:app--reloadThen visithttps://127.0.0.1:8000/upload.thmlReferencesGitHub - tus/tus-resumable-upload-protocol: Open Protocol for Resumable File Uploads
Package: fastapi-users-db-beanie
FastAPI Users - Database adapter for BeanieReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for Beanie support in FastAPI Users.DevelopmentSetup environmentWe useHatchto manage the development environment and production build. Ensure it's installed on your system.Run unit testsYou can run all the tests with:hatchruntestFormat the codeExecute the following command to applyisortandblackformatting:hatchrunlintLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-db-deta
FastAPI Users DB DetaSub-package for Deta Base support in FastAPI Users.Free software: MIT licenseDocumentation:https://fastapi-users-db-deta.readthedocs.io.InstallationTo install FastAPI Users DB Deta in a project:pip install -U fastapi_users_db_detaUsageProject structure:.
├── users
│   ├── __init__.py
│   ├── models.py
│   ├── manager.py
└── main.pyusers/models.py:from fastapi_users import models
from fastapi_users.models import BaseOAuthAccountMixin


class User(models.BaseUser, BaseOAuthAccountMixin):
    pass


class UserCreate(models.BaseUserCreate):
    pass


class UserUpdate(models.BaseUserUpdate):
    pass


class UserDB(User, models.BaseUserDB):
    passusers/manager.py:from typing import Optional

import deta
from fastapi import Depends, Request
from fastapi_users import BaseUserManager, FastAPIUsers
from fastapi_users.authentication import JWTAuthentication, CookieAuthentication
from fastapi_users_db_deta import DetaBaseUserDatabase

from users.models import UserDB, UserCreate, UserUpdate, User

SECRET = 'secret'
DETA_PROJECT_KEY = 'deta_project_key'
DATABASE = deta.Deta(DETA_PROJECT_KEY)
UserBase = DATABASE.Base('users')
OAuthBase = DATABASE.Base('oauth_accounts')


class UserManager(BaseUserManager[UserCreate, UserDB]):
    user_db_model = UserDB
    reset_password_token_secret = SECRET
    verification_token_secret = SECRET


async def get_user_db():
    yield DetaBaseUserDatabase(UserDB, UserBase().db, OAuthBase().db)


async def get_user_manager(user_db=Depends(get_user_db)):
    yield UserManager(user_db)


jwt_authentication = JWTAuthentication(
    secret=SECRET, lifetime_seconds=5, tokenUrl="auth/jwt/login"
)
cookie_authentication = CookieAuthentication(
    secret=SECRET, lifetime_seconds=5, cookie_name='userAuthToken'
)

fastapi_users_app = FastAPIUsers(
    get_user_manager,
    [jwt_authentication, cookie_authentication],
    User,
    UserCreate,
    UserUpdate,
    UserDB,
)

current_active_user = fastapi_users_app.current_user(active=True)main.py:from fastapi import FastAPI

from users.manager import cookie_authentication, jwt_authentication, fastapi_users_app

app = FastAPI()

# include cookie auth router
app.include_router(
    fastapi_users_app.get_auth_router(
        cookie_authentication,
    ), prefix="/auth/cookie", tags=["auth"]
)

# include jwt auth router
app.include_router(
    fastapi_users_app.get_auth_router(
        jwt_authentication,
    ), prefix="/auth/jwt", tags=["auth"]
)

app.include_router(
    fastapi_users_app.get_register_router(), prefix="/auth", tags=["auth"]
)

app.include_router(
    fastapi_users_app.get_reset_password_router(),
    prefix="/auth",
    tags=["auth"],
)

app.include_router(
    fastapi_users_app.get_verify_router(),
    prefix="/auth",
    tags=["auth"],
)

app.include_router(
    fastapi_users_app.get_users_router(), prefix="/users", tags=["users"]
)CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2021-11-17)First release on PyPI.
Package: fastapi-users-db-mongodb
FastAPI Users - Database adapter for MongoDBReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for MongoDB support in FastAPI Users.DevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:pipinstall-rrequirements.dev.txtRun unit testsYou can run all the tests with:maketestThe command will start a MongoDB container for the related unit tests. So you should haveDockerinstalled.Alternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-db-mongodb-azure
FastAPI Users - Database adapter for MongoDBThis is a fork of the driver to deploy with CosmosDB Mongo DriverReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for MongoDB support in FastAPI Users.DevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:pipinstall-rrequirements.dev.txtRun unit testsYou can run all the tests with:maketestThe command will start a MongoDB container for the related unit tests. So you should haveDockerinstalled.Alternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-db-opensearch
FastAPI Users - Database adapter for OpenSearchReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for OpenSearch support in FastAPI Users.DevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:pipinstall-rrequirements.dev.txtRun unit testsYou can run all the tests with:maketestAlternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-db-ormar
FastAPI Users - Database adapter for ormarReady-to-use and customizable users management for FastAPIDocumentation:https://frankie567.github.io/fastapi-users/Source Code:https://github.com/frankie567/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for ormar support in FastAPI Users.DevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:pipinstall-rrequirements.dev.txtRun unit testsYou can run all the tests with:maketestAlternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-db-sqlalchemy
FastAPI Users - Database adapter for SQLAlchemy ORMReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for SQLAlchemy ORM support in FastAPI Users.DevelopmentSetup environmentWe useHatchto manage the development environment and production build. Ensure it's installed on your system.Run unit testsYou can run all the tests with:hatchruntestFormat the codeExecute the following command to applyisortandblackformatting:hatchrunlintLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-db-sqlmodel
FastAPI Users - Database adapter for SQLModelReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for SQLModel support in FastAPI Users.DevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:pipinstall-rrequirements.dev.txtRun unit testsYou can run all the tests with:maketestAlternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi_users_db_sync_sqlalchemy
FastAPI Users - Database adapter for Sync SQLAlchemy ORMReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for SQLAlchemy ORM support in FastAPI Users.DevelopmentSetup environmentWe useHatchto manage the development environment and production build. Ensure it's installed on your system.Run unit testsYou can run all the tests with:hatchruntestFormat the codeExecute the following command to applyisortandblackformatting:hatchrunlintLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-db-tortoise
FastAPI Users - Database adapter for Tortoise ORMReady-to-use and customizable users management for FastAPIDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for Tortoise ORM support in FastAPI Users.DevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:pipinstall-rrequirements.dev.txtRun unit testsYou can run all the tests with:maketestAlternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.
Package: fastapiusers-edgedb
FastAPI Users - Database adapter for EdgeDBDocumentation:https://fastapi-users.github.io/fastapi-users/Source Code:https://github.com/fastapi-users/fastapi-usersAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for EdgeDB support in FastAPI Users.DevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:makeinstallRun unit testsYou can run all the tests with:maketestAlternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.
Package: fastapi-users-ormar-ext
fastapi-users-ormar-extExtension to use ormar in fastapi-usersInstallationTo install use:pipinstallfastapi-users-ormar-extUsageExample:fromtypingimportOptionalimportormarfromfastapi_users_ormar_extimport(OrmarBaseUserTableUUID,OrmarBaseOAuthAccountTableUUID,)classBaseMeta(ormar.ModelMeta):"""Base metadata for models."""database=databasemetadata=metaclassUser(OrmarBaseUserTableUUID):classMeta(BaseMeta):passphone:str=ormar.String(nullable=False,max_length=100)classOAuthAccount(OrmarBaseOAuthAccountTableUUID):classMeta(BaseMeta):passuser:User=ormar.ForeignKey(User,nullable=False,ondelete="cascade")TODO[ ] Think of a way to forceuserfield overriding in OrmarBaseOAuthAccountTableUUID
[ ] Add tests
Package: fastapi-users-ormar-extension
fastapi-users-ormar-extExtension to use ormar in fastapi-usersInstallationTo install use:pipinstallfastapi-users-ormar-extensionUsageExample:fromtypingimportOptionalimportormarfromfastapi_users_ormar_extensionimport(OrmarBaseUserTableUUID,OrmarBaseOAuthAccountTableUUID,)classBaseMeta(ormar.ModelMeta):"""Base metadata for models."""database=databasemetadata=metaclassUser(OrmarBaseUserTableUUID):classMeta(BaseMeta):passphone:str=ormar.String(nullable=False,max_length=100)classOAuthAccount(OrmarBaseOAuthAccountTableUUID):classMeta(BaseMeta):passuser:User=ormar.ForeignKey(User,nullable=False,ondelete="cascade")TODO[ ] Think of a way to forceuserfield overriding in OrmarBaseOAuthAccountTableUUID
[ ] Add tests
Package: fastapi-users-tortoise
FastAPI Users - Database adapter for Tortoise ORMTortoise orm database adapter forfastapi-users v10and above.
If you want an example of a project using this or just bootstrap your project with fastapi-users and tortoise, you can check out the cookiecutter I'm working onhere.Documentation:https://tobi-de.github.io/fastapi-users-tortoiseSource Code:https://github.com/tobi-de/fastapi-users-tortoiseAdd quickly a registration and authentication system to yourFastAPIproject.FastAPI Usersis designed to be as customizable and adaptable as possible.Sub-package for Tortoise ORM support in FastAPI Users.Installationpipinstallfastapi-users-tortoiseDevelopmentSetup environmentYou should create a virtual environment and activate it:python-mvenvvenv/sourcevenv/bin/activateAnd then install the development dependencies:pipinstall-rrequirements.dev.txtRun unit testsYou can run all the tests with:maketestAlternatively, you can runpytestyourself:pytestThere are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:ulimit-n2048Format the codeExecute the following command to applyisortandblackformatting:makeformatLicenseThis project is licensed under the terms of the MIT license.