Skip to content

Instantly share code, notes, and snippets.

View wshayes's full-sized avatar

William Hayes wshayes

View GitHub Profile
@wshayes
wshayes / comments
Last active November 15, 2023 11:34 — forked from dmontagu/main.py
[FastAPI app with response shape wrapping] #fastapi
From FastAPI Gitter:
dmontagu @dmontagu 00:14
@wshayes @intrepidOlivia here is a fully self-contained working implementation of a wrapped response
https://gist.github.com/dmontagu/9abbeb86fd53556e2c3d9bf8908f81bb
you can set context data and errors on the starlette Request and they get added to the response at the end
(@intrepidOlivia if you save the contents of that gist to main.py it should be possible to run via uvicorn main:app --reload)
if the endpoint failed in an expected way and you want to return a StandardResponse with no data field, you provide the type of StandardResponse you want to return instead of an instance
@wshayes
wshayes / log.py
Last active June 29, 2023 06:50 — forked from djlambert/log.py
[FastAPI Websocket Example] Example of using websockets with FastAPI #fastapi #websockets
import asyncio
import json
from uuid import UUID
import aio_pika
import websockets.exceptions as ws_exc
from fastapi import APIRouter
from starlette.websockets import WebSocket
from conf.app import config
@wshayes
wshayes / CLA.md
Created July 5, 2017 17:19 — forked from balloob/CLA.md
CLA for Apache 2.0 license

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I have the right to submit it under the Apache 2.0 license; or

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the Apache 2.0 license; or

@wshayes
wshayes / Readme.md
Created March 6, 2016 17:07 — forked from peisenmann/Readme.md
hover-color Aurelia custom attribute

The important things to note in this gist are:

app.html The usage of the custom attribute hover-color is <div hover-color="special-hover-class"> where special-hover-class is simply a css class that will be applied to all hover-color elements when the given element is hovered.

hover-color.js This is the source code of the custom attribute itself, and is commented to explain what it does. Essentially, if the element is hovered, the custom attribute sends out a message to tell all other hover color elements to change. When the mouse leaves the element, a message is broadcast to tell them all to remove their class change.