Skip to content

Commit

Permalink
remove cruft.json
Browse files Browse the repository at this point in the history
  • Loading branch information
kjaymiller committed Feb 1, 2024
1 parent 1072e1a commit a581609
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/Azure-Samples/Azure-Python-Standardization-Template-Generator",
"commit": "621af12f962b64b1f3458b83fa1af0898d565d80",
"commit": "0178d866789d5eef0d9b6769673640cbada8b3b9",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
2 changes: 0 additions & 2 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get update && apt-get install -y xdg-utils \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

RUN python -m pip install --upgrade pip

WORKDIR /demo-code

COPY requirements.txt .
Expand Down
12 changes: 10 additions & 2 deletions src/fastapi_app/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import pathlib

from azure.monitor.opentelemetry import configure_azure_monitor
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
Expand All @@ -9,6 +10,9 @@

from .models import Cruise, Destination, InfoRequest, engine

if os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING"):
configure_azure_monitor()

app = FastAPI()
parent_path = pathlib.Path(__file__).parent.parent
app.mount("/mount", StaticFiles(directory=parent_path / "static"), name="static")
Expand Down Expand Up @@ -39,14 +43,18 @@ def destinations(request: Request):
def destination_detail(request: Request, pk: int):
with Session(engine) as session:
destination = session.exec(select(Destination).where(Destination.id == pk)).first()
return templates.TemplateResponse("destination_detail.html", {"request": request, "destination": destination})
return templates.TemplateResponse(
"destination_detail.html", {"request": request, "destination": destination, "cruises": destination.cruises}
)


@app.get("/cruise/{pk}")
def cruise_detail(request: Request, pk: int):
with Session(engine) as session:
cruise = session.exec(select(Cruise).where(Cruise.id == pk)).first()
return templates.TemplateResponse("cruise_detail.html", {"request": request, "cruise": cruise})
return templates.TemplateResponse(
"cruise_detail.html", {"request": request, "cruise": cruise, "destinations": cruise.destinations}
)


@app.get("/info_request/", response_class=HTMLResponse)
Expand Down
1 change: 1 addition & 0 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "fastapi_app"
version = "1.0.0"
description = "Create a relecloud demo application with fastapi and cosmos-postgres"
dependencies = [
"azure-monitor-opentelemetry",
"fastapi",
"jinja2",
"uvicorn[standard]",
Expand Down
2 changes: 1 addition & 1 deletion src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<link rel="apple-touch-icon" sizes="120x120" href="{{ url_for('static', path='res/img/favicon-120-precomposed.png') }}">

<!-- Chrome for Android -->
<link rel="manifest" href="{{ url_for('static', path='manifest.json') }}}}">
<link rel="manifest" href="{{ url_for('static', path='manifest.json') }}">
<link rel="icon" sizes="192x192" href="{{ url_for('static', path='res/img/favicon-192.png') }}">

<title>
Expand Down

0 comments on commit a581609

Please sign in to comment.