- Who is your craziest/most interesting relative?
- What’s a weird fact you happen to know?
- What’s your strangest talent?
- Everyone has those recurring bad dreams … what is your nightmare?
- What is your favorite smell and why?
- What completely safe animal are you inexplicably afraid of?
- What do you pretend to hate but actually love?
- If you had a boat, what would you name it?
- What was your first job?
- Have you ever met anyone famous?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 ipython -i | |
import datetime | |
import json | |
from typing import Optional | |
import sqlalchemy as sa | |
from sqlalchemy.orm import declarative_base, sessionmaker | |
from sqlalchemy.dialects.postgresql import JSONB | |
from pydantic import BaseModel, Field, parse_obj_as |
Problem: FastAPI doesn't accept JSON-encoded pydantic models in query strings. See #884.
Solution: Use json_param()
from the snippet below.
Usage example.
from fastapi import FastAPI
from pydantic import BaseModel
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 requests | |
from requests.adapters import HTTPAdapter | |
from urllib3.util.retry import Retry | |
USER_AGENT = "My project (https://example.com)" | |
def get_default_session() -> requests.Session: | |
"""Return a request.Session() instance with reasonable defaults for retries. |
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
""" | |
A simple contrived example of a FastAPI application that heavily uses | |
the FastAPI dependency injection system. | |
Sample request http://127.0.0.1:9876/tasks?user_id=123456 | |
returns [{"id":1,"name":"Task 1","user":{"id":123456,"name":"John Doe"}}] | |
Dependency tree: | |
get_me() |
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
You are a powerful agentic AI coding assistant, powered by GPT-4o. You operate exclusively in Cursor, the world's best IDE. | |
You are pair programming with a USER to solve their coding task. | |
The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question. | |
Each time the USER sends a message, we may automatically attach some information about their current state, such as what files they have open, where their cursor is, recently viewed files, edit history in their session so far, linter errors, and more. | |
This information may or may not be relevant to the coding task, it is up for you to decide. | |
Your main goal is to follow the USER's instructions at each message. | |
<communication> | |
1. Be conversational but professional. |
OlderNewer