This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"version":1,"resource":"file:///home/marcelo/Development/personal/fastapix/fastapix/loader.py","entries":[{"id":"BxHT.py","timestamp":1666628557303},{"id":"L1X5.py","timestamp":1666628585759},{"id":"QW4O.py","source":"Workspace Edit","timestamp":1666628588867},{"id":"AS97.py","timestamp":1666628591388},{"id":"JbgL.py","timestamp":1666628645376},{"id":"dwcf.py","source":"Workspace Edit","timestamp":1666628655876},{"id":"8sP0.py","timestamp":1666628671132},{"id":"HtJ7.py","source":"Workspace Edit","timestamp":1666628673152}]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from typing import Type | |
from aio_pika import RobustConnection, connect_robust | |
from aio_pika.connection import ConnectionType | |
from aio_pika.types import TimeoutType | |
class RabbitMQClient: | |
def __init__( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import Body, FastAPI | |
from fastapi.routing import APIRoute, APIRouter | |
from humps import camelize | |
from pydantic import BaseModel | |
app = FastAPI() | |
router = APIRouter(prefix="/haha") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Snippet that demonstrates how to use Gunicorn with Uvicorn workers in code. | |
Feel free to run: | |
- `python main.py` - to use uvicorn. | |
- `ENV=prod python main.py` - to use gunicorn with uvicorn workers. | |
Reference: https://docs.gunicorn.org/en/stable/custom.html | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import APIRouter, FastAPI | |
from utils import create_versioning_docs | |
app = FastAPI(docs_url=None, redoc_url=None) | |
v1_router = APIRouter(prefix="/v1") | |
v2_router = APIRouter(prefix="/v2") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
from fastapi import FastAPI | |
from fastapi.openapi.utils import get_openapi | |
app = FastAPI() | |
def custom_openapi(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Script to export the ReDoc documentation page into a standalone HTML file. | |
Created by https://github.com/pawamoy on https://github.com/Redocly/redoc/issues/726#issuecomment-645414239 | |
""" | |
import json | |
from my_app.app import app | |
HTML_TEMPLATE = """<!DOCTYPE html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import subprocess | |
import sys | |
branch_name = subprocess.check_output("git rev-parse --abbrev-ref HEAD".split()).decode().strip() | |
jira_ticket = "-".join(branch_name.split("-")[:2]) | |
commit_msg = f"[{jira_ticket}] {sys.argv[1]}" | |
sys.argv[1] = commit_msg | |
gcmsg_args = sys.argv[1:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from typing import TYPE_CHECKING, Awaitable, Callable, TypedDict, TypeVar | |
from starlette.datastructures import MutableHeaders | |
from typing_extensions import NotRequired | |
if TYPE_CHECKING: | |
from asgiref.typing import ( | |
ASGI3Application, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import anyio | |
from fastapi import FastAPI | |
app = FastAPI() | |
@app.on_event("startup") | |
async def startup(): | |
limiter = anyio.to_thread.current_default_thread_limiter() |
OlderNewer