Skip to content

Commit

Permalink
Update setup-azd version (edgio issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
reneenoble committed Jan 9, 2025
1 parent aa8648c commit 8fbf7fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 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": "573edb00d58171b2848ed4d1032fc6aae8fe0cea",
"commit": "94513c0c679a5809e0b80787e3b9a340a10a6450",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/checkout@v4

- name: Install azd
uses: Azure/setup-azd@v1.0.0
uses: Azure/setup-azd@v2

- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
Expand Down
24 changes: 17 additions & 7 deletions src/fastapi_app/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import pathlib
from typing import Annotated

from azure.monitor.opentelemetry import configure_azure_monitor
from fastapi import FastAPI, Request
from fastapi import FastAPI, Form, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
Expand Down Expand Up @@ -59,14 +60,23 @@ def cruise_detail(request: Request, pk: int):

@app.get("/info_request/", response_class=HTMLResponse)
def info_request(request: Request):
return templates.TemplateResponse("info_request_create.html", {"request": request})
with Session(engine) as session:
all_cruises = session.exec(select(Cruise)).all()
return templates.TemplateResponse("info_request_create.html", {"request": request, "cruises": all_cruises})


@app.post("/info_request/", response_model=InfoRequest)
def create_info_request(info_request: InfoRequest):
def create_info_request(request: Request, info_request: Annotated[InfoRequest, Form()]):
with Session(engine) as session:
db_info_request = InfoRequest.from_orm(info_request)
session.add(db_info_request)
session.add(info_request)
session.commit()
session.refresh(db_info_request)
return db_info_request
session.refresh(info_request)
all_cruises = session.exec(select(Cruise)).all()
return templates.TemplateResponse(
"info_request_create.html",
{
"request": request,
"cruises": all_cruises,
"message": "Information request submitted.",
},
)

0 comments on commit 8fbf7fc

Please sign in to comment.