semvec/pypi-packages huggingface dataset:
jiushu_logger_starlette 1.0.2
Jiushu logger for Starlette/FastAPI routes.
Requires Python: >=3.8

![logo.png](logo.png)
# jiushu-logger-starlette【九书 Starlette / FastAPI 路由专用】

## 简介

JF 专用格式化 logger 的 Starlette / FastAPI 路由特供版，专门输出请求日志。

## 使用方法

```python
from asyncio import sleep

from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.requests import Request
from starlette.responses import PlainTextResponse, JSONResponse
from starlette.routing import Route, Mount

from jiushu_logger_starlette.route_logging_middleware import RouterLoggingMiddleware


async def _test(request: Request):
    # You can get trace id of *this* request.
    # If apache-skywalking is used, this trace_id will be the ID tracing by skywalking.
    return PlainTextResponse(request.state.trace_id.encode('utf_8'))


async def _test2(request: Request):
    await sleep(1.23456)
    return JSONResponse({'result': True}, headers={'Content-Type': 'application/json'})


async def _should_be_skip(request: Request):
    return PlainTextResponse(b'Hello, world!')


async def _health(request: Request):
    return JSONResponse({'status': 'UP'}, headers={'Content-Type': 'application/json'})


routes = [
    Mount('/api', routes=[
        Route('/test', _test),
        Route('/test2', _test2, methods=['GET', 'POST']),
        Route('/should-be-skip', _should_be_skip),
        Route('/health', _health),
    ])
]
middleware = [
    # Logging for routes.
    # You can set which route should be skipped, 
    #   or which pattern the route matches should be skipped.
    Middleware(RouterLoggingMiddleware,
               skip_routes=['/api/health'],
               skip_regexes=[r'''^.*skip.*$'''])
]
app = Starlette(routes=routes, middleware=middleware)
```
s1crets 0.0.12
Convenience wrapper for AWS Parameter Store/Secrets Manager

s1crets
=======

s1crets is a thin Python wrapper to read secrets from cloud resources.
Wherever supported, it can be used to read/update non-encrypted values as well.

You can find its documentation at `readthedocs.io
<https://s1crets.readthedocs.io/en/latest/>`_

Installing
----------

Install and update using `pip`_:

.. code-block:: text

    pip install -U s1crets

A Simple Example
----------------

.. code-block:: python

    # Using AWS Parameter Store
    import s1crets.providers.aws
    ps = s1crets.providers.aws.ParameterStore()
    ps.get('/prod/databases/mysql/bigdb/root')
    ps.get_by_path('/prod/databases/mysql')
    ps.path_exists('/prod/databases/mysql')
    ps.update('/prod/databases/mysql/bigdb/root', 'S3cr3Tp4Ssw0Rd!^')

    # AWS Secrets Manager
    sm = s1crets.providers.aws.SecretsManager()
    sm.get('prod/databases/mysql/bigdb/root')
    sm.path_exists('prod/databases/mysql')
    sm.update('prod/databases/mysql/bigdb/root', 'S3cr3Tp4Ssw0Rd!^')


.. code-block:: text

    $ s1crets get secrets/json_test
    {'level1': {'level2': 3}}
    $ s1crets get secrets/json_test level1
    {'level2': 3}
    $ s1crets get secrets/json_test level1 level2
    3


Getting secrets from a different (than configured) region:

.. code-block:: python

    import s1crets.providers.aws
    sm = s1crets.providers.aws.SecretsManager(sts_args={"aws_region": "us-east-1"})
    sm.get("secret-from-us-east-1")


This library is developed and used internally at `System1
<https://system1.com/>`_

.. _pip: https://pip.pypa.io/en/stable/quickstart/