kenken999's picture
fda
a61be63
raw
history blame
783 Bytes
from django.shortcuts import render
from .models import Diamond, BrandProduct
from fastapi import FastAPI
app = FastAPI()
@app.get("/diamonds/")
def get_diamonds():
diamonds = Diamond.objects.all()
return {"diamonds": [{"id": d.id, "carat": d.carat, "cut": d.cut, "color": d.color, "clarity": d.clarity, "depth": d.depth} for d in diamonds]}
@app.get("/brand_products/")
def get_brand_products():
brand_products = BrandProduct.objects.all()
return {"brand_products": [{"id": bp.id, "brand_name": bp.brand_name, "model_name": bp.model_name, "type_number": bp.type_number, "purchase_store": bp.purchase_store, "purchase_date": bp.purchase_date, "purchase_price": bp.purchase_price, "accessories": bp.accessories, "condition": bp.condition} for bp in brand_products]}