Skip to content

Instantly share code, notes, and snippets.

@CareTiger
CareTiger / fastapi_inside_jupyter.md
Created September 18, 2023 06:32 — forked from raveenb/fastapi_inside_jupyter.md
Run FastAPI inside Jupyter

How to Run FastAPI inside Jupyter

  • Ensure you have these installed and accessible from the notebook pyngrok, nest_asyncio, fastapi, uvicorn and other libs you want
%pip install pyngrok nest_asyncio fastapi uvicorn loguru
  • Create a FastAPI app
from fastapi import FastAPI
@aleixmorgadas
aleixmorgadas / 0_README.md
Last active June 24, 2024 12:30
Starting a FastAPI as a server mock

Using FastAPI as Server Mock

I wanted to start a real mock server with real instances that I could fine tune for my own needs.

I found a way to start the FastAPI to run the tests agains it, and then kill the uvicorn.

Here an example code 👍

image

@Shaunwei
Shaunwei / main.py
Last active July 10, 2023 15:02
Microsoft Guidance OpenAI function calling template
from openai_function_call import openai_function
import guidance
@openai_function
def get_weather(location: str, unit: str = 'fahrenheit', date: str = 'today'):
""" Get the current weather in a given location and date."""
weather_info = {
'location': location,
'unit': unit,
'temperature': '60' if unit == 'fahrenheit' else '15',
@JavascriptMick
JavascriptMick / Header.vue
Created May 12, 2023 13:39
Vue 3 Toast notifications using Pinia and DaisyUI
<script setup lang="ts">
import { storeToRefs } from 'pinia';
const notifyStore = useNotifyStore();
const { notifications } = storeToRefs(notifyStore);
</script>
<template>
....
<div class="toast toast-end toast-top">
<div v-for="notification in notifications" :class="notification.type">
@inspirit941
inspirit941 / 23-04-23-aifactory-langchain-2.ipynb
Created April 24, 2023 04:27
23.04.23 - aifactory 김태영 - LangChain 시작하기 (2).ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Atinux
Atinux / sse.ts
Last active July 16, 2024 13:45
SSE endpoint example with Nuxt 3
// ~/server/api/sse.ts
export default defineEventHandler(async (event) => {
if (!process.dev) return { disabled: true }
// Enable SSE endpoint
setHeader(event, 'cache-control', 'no-cache')
setHeader(event, 'connection', 'keep-alive')
setHeader(event, 'content-type', 'text/event-stream')
setResponseStatus(event, 200)
# Reference: https://indominusbyte.github.io/fastapi-jwt-auth/usage/basic/
from fastapi import FastAPI, Depends, Request, HTTPException
from fastapi.responses import JSONResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTException
from pydantic import BaseModel
app = FastAPI()
@AD0791
AD0791 / api_version.py
Created March 18, 2022 15:36
advanced_fastapi
from fastapi import FastAPI
apiv1 = FastAPI()
@apiv1.get('/returnName')
def index():
return {"Name": "Kaustubh demo"}
#################
@danielroe
danielroe / settings.json
Last active July 15, 2024 12:07
VScode settings for a minimal UI
{
// Disable telemetry
"telemetry.telemetryLevel": "off",
// Zen mode
"zenMode.fullScreen": false,
"zenMode.hideTabs": true,
"zenMode.centerLayout": false,
// Theming
"workbench.iconTheme": "city-lights-icons-vsc",
"editor.fontFamily": "Dank Mono",
@sandys
sandys / Fastapi-sqlalchemy-pydantic-dataclasses-reloadable-logging.md
Last active June 30, 2024 09:23
fastapi with python 3.10 dataclasses - used to create both sqlalchemy and pydantic models simultaneously. And setting up sqlalchemy the right way (without deadlocks or other problems). Additionally, this also takes care of unified logging when running under gunicorn..as well as being able to run in restartable mode.