Skip to content

Instantly share code, notes, and snippets.

@fliepeltje
fliepeltje / app.py
Created July 25, 2024 10:58
FastAPI with ollama on Fly.io
import os
from fastapi import FastAPI
from ollama import AsyncClient
OLLAMA_HOST = os.getenv('OLLAMA_HOST')
ollama_client = AsyncClient(OLLAMA_HOST)
app = FastAPI()
@app.get("/")
async def read_root():
@fliepeltje
fliepeltje / app.py
Created July 25, 2024 10:28
FastAPI with boto3 on Fly.io
import os
import boto3
from fastapi import FastAPI
S3_URL = os.getenv("AWS_ENDPOINT_URL_S3")
svc = boto3.client('s3', endpoint_url=S3_URL)
app = FastAPI()
@app.get("/")
@fliepeltje
fliepeltje / app.py
Created July 25, 2024 09:47
FastAPI app with asyncpg minimal example
import os
import asyncpg
from fastapi import FastAPI
DATABASE_URL = os.getenv("DATABASE_URL")
app = FastAPI()
async def get_db_meta():
conn = await asyncpg.connect(DATABASE_URL)
records = await conn.fetch("select nspname from pg_namespace;")