"""Source-grounded Lowe's offline clone frontend shell.
The visual states and local image assets are derived from the Playwright
evidence pack in materials/lowes/source-current and source-assets.
"""
from __future__ import annotations
import json
from html import escape
from pathlib import Path
from typing import Any, Mapping, Sequence
from urllib.parse import parse_qs, quote_plus, urlencode
from fastapi import FastAPI, Request, Response
from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
import commerce
import landing
from backend import accounts as account_backend
from backend import store as site_store
from ui.artwork import VIEWS, product_svg
SITE_ID = "lowes"
DISPLAY_NAME = "Lowe's"
ROOT = Path(__file__).resolve().parent
MATERIAL_ROOT = ROOT.parent
STATIC_ROOT = ROOT / "static"
ASSET_ROOT = MATERIAL_ROOT / "source-assets" / "playwright-20260821"
MULTIPAGE_ASSET_ROOT = STATIC_ROOT / "assets" / "playwright-multipage-20260821"
app = FastAPI(title=DISPLAY_NAME)
app.mount("/static", StaticFiles(directory=STATIC_ROOT), name="static")
app.mount("/source-assets", StaticFiles(directory=ASSET_ROOT), name="source-assets")
app.mount(
"/multipage-assets",
StaticFiles(directory=MULTIPAGE_ASSET_ROOT),
name="multipage-assets",
)
PRODUCTS = [
{
"backend_id": 1001,
"slug": "frigidaire-professional-french-door-refrigerator",
"brand": "Frigidaire Professional",
"title": "21.4-cu ft Counter-Depth French Door Refrigerator with Dual Ice Maker",
"price": 2999.00,
"was": 3999.00,
"rating": "4.6",
"reviews": 812,
"image": "005-753ec6507385a84d.avif",
"category": "Appliances",
},
{
"backend_id": 1002,
"slug": "frigidaire-professional-convection-range",
"brand": "Frigidaire Professional",
"title": "30-in 6-Burner Convection Range with Air Fry",
"price": 1699.00,
"was": 2999.00,
"rating": "4.7",
"reviews": 441,
"image": "005-289c2ff5d6cb25ae.avif",
"category": "Appliances",
},
{
"backend_id": 1005,
"slug": "frigidaire-gallery-french-door-refrigerator",
"brand": "Frigidaire Gallery",
"title": "French Door Refrigerator with Custom-Flex Temp Drawer",
"price": 1999.00,
"was": 2799.00,
"rating": "4.5",
"reviews": 668,
"image": "005-dfaf191432b00001.avif",
"category": "Appliances",
},
{
"backend_id": 1006,
"slug": "frigidaire-energy-star-refrigerator",
"brand": "Frigidaire",
"title": "ENERGY STAR French Door Refrigerator with Ice Maker",
"price": 1599.00,
"was": 2399.00,
"rating": "4.4",
"reviews": 503,
"image": "009-82acfde0786311c2.avif",
"category": "Appliances",
},
{
"backend_id": 1003,
"slug": "frigidaire-dishwasher",
"brand": "Frigidaire",
"title": "Top Control 24-in Built-In Dishwasher",
"price": 499.00,
"was": 649.00,
"rating": "4.3",
"reviews": 1159,
"image": "011-c6564a958b49fc75.avif",
"category": "Appliances",
},
{
"backend_id": 1004,
"slug": "electrolux-front-load-laundry-pair",
"brand": "Electrolux",
"title": "Front-Load Washer and Electric Dryer Laundry Pair",
"price": 1599.00,
"was": 2199.00,
"rating": "4.6",
"reviews": 924,
"image": "011-baeb3a51751a722c.avif",
"category": "Appliances",
},
]
BEST_SELLER_DEPARTMENTS = [
("Accessible Home", "6af8471da47c294fdc6c.webp"),
("Animal & Pet Care", "41a8e365a49148ee412e.webp"),
("Appliances", "ba41fa97d7383500c4b6.webp"),
("Automotive", "6c36e70a664e0848d90d.avif"),
("Bathroom", "dda585b6cae61ddd07ea.webp"),
("Building Supplies", "dd7f3b1d215945e9f098.avif"),
("Cleaning Supplies", "d2732d99a54a164ff9fe.webp"),
("Clothing & Work Apparel", "eed3b304716ed0e28843.webp"),
("Dining & Entertaining", "1c049e30d66740306d57.avif"),
("Drinks & Snacks", "a1a0b97fcf109d04fd4a.webp"),
("Electrical", "1e30e7d63a3040a0bf02.webp"),
("Flooring", "3f72678a92b47aca55df.webp"),
]
STATES = {
"A": ["Alabama", "Alaska", "Arizona", "Arkansas"],
"C": ["California", "Colorado", "Connecticut"],
"D": ["Delaware", "District Of Columbia"],
"F": ["Florida"],
"G": ["Georgia"],
"H": ["Hawaii"],
"I": ["Idaho", "Illinois", "Indiana", "Iowa"],
"K": ["Kansas", "Kentucky"],
"L": ["Louisiana"],
"M": ["Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana"],
"N": ["Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota"],
"O": ["Ohio", "Oklahoma", "Oregon"],
"P": ["Pennsylvania"],
"R": ["Rhode Island"],
"S": ["South Carolina", "South Dakota"],
"T": ["Tennessee", "Texas"],
"U": ["Utah"],
"V": ["Vermont", "Virginia"],
"W": ["Washington", "West Virginia", "Wisconsin", "Wyoming"],
}
# Routes that predate the source-path inventory and are still reachable from
# bookmarks. Each one now names the source-compatible path it belongs to, so the
# clone has a single canonical URL per surface instead of two parallel ones.
LEGACY_REDIRECTS = {
"credit": "/l/Credit",
"pro": "/l/Pro",
"ai-assist": "/ai",
"installations": "/l/install",
"ideas": "/diy-projects-and-ideas",
"maintenance": "/l/shop/home-maintenance",
"terms": "/l/about/terms-and-conditions-of-use",
"privacy": "/l/about/privacy-and-security-statement",
"info": "/l/help",
}
# The Playwright probe recorded Access Denied for most source paths, so pages
# reconstructed from a URL alone say so in one consistent sentence rather than
# implying a verified reproduction.
SOURCE_RESTRICTED_NOTE = landing.SOURCE_RESTRICTED_NOTE
SYNTHETIC_COMMERCE_NOTE = (
"Prices, ratings, reviews, specifications and artwork on this page come "
"from this clone's frozen synthetic catalog, not from Lowe's. The source "
"page answered Access Denied to the recorded Playwright session, so no "
"source layout or product data was observed for it."
)
EMPTY_CART: dict[str, Any] = {
"items": [],
"count": 0,
"units": 0,
"subtotal_cents": 0,
"savings_cents": 0,
"needs_delivery": False,
"all_free_delivery": True,
}
def money(value: float) -> str:
return f"${value:,.2f}"
def cents(value: int) -> str:
return f"${site_store.money(int(value))}"
def product_by_slug(slug: str) -> dict[str, object] | None:
return next((product for product in PRODUCTS if product["slug"] == slug), None)
CAPTURED_BY_BACKEND_ID = {int(item["backend_id"]): item for item in PRODUCTS}
def captured_product(product_id: int) -> dict[str, object] | None:
"""The captured-asset display record for a backend id, when there is one."""
return CAPTURED_BY_BACKEND_ID.get(int(product_id))
def catalog_art(product_id: int, view: str = "front") -> str:
"""Locally generated artwork URL for any catalog product."""
return f"/img/p/{int(product_id)}/{view}.svg"
# ---------------------------------------------------------------------------
# shared page furniture
# ---------------------------------------------------------------------------
def breadcrumb_bar(trail: Sequence[tuple[str, str | None]]) -> str:
parts = []
for label, href in trail:
if href:
parts.append(f'{escape(label)}')
else:
parts.append(f"{escape(label)}")
return (
'"
)
def sandbox_notice(text: str) -> str:
return f'
{escape(text)}
'
def action_row(actions: Sequence[tuple[str, str]]) -> str:
if not actions:
return ""
links = "".join(
f'{escape(label)}'
for label, href in actions
)
return f'
{links}
'
def highlight_grid(highlights: Sequence[tuple[str, str]]) -> str:
if not highlights:
return ""
cards = "".join(
f"
{escape(title)}
{escape(copy)}
"
for title, copy in highlights
)
return f'
{cards}
'
def fact_table(facts: Sequence[tuple[str, str]]) -> str:
if not facts:
return ""
rows = "".join(
f'
'
)
def drawer(opened: bool = False, account: dict[str, Any] | None = None) -> str:
hidden = "hidden" if not opened else ""
state = "open" if opened else "closed"
if account:
title = "Your Account"
contents = f"""
Signed in as {escape(str(account.get('contact_display', '')))} in this offline clone. Nothing here exists at Lowe's.
Signing out revokes this local session on the server before the cookie is deleted.
{DRAWER_BENEFITS}"""
else:
title = "Sign In or Create Account"
contents = f"""
Enter your email or phone number to get started. We'll check if you have an account.
"""
return render(request, "Lowe's Best Sellers - The Most Popular Items on Lowes.com", body)
@app.get("/diy-projects-and-ideas/workshops", response_class=HTMLResponse)
def workshops(request: Request) -> HTMLResponse:
body = """
'
return render(request, f"Shop {label} at Lowes.com", body)
@app.get("/api/suggest")
def suggest(q: str = "") -> JSONResponse:
needle = q.strip().lower()
labels = ["cordless drill", "refrigerator", "refrigerator water filter", "Frigidaire appliances", "dishwasher", "range", "washer and dryer"]
matched = [label for label in labels if needle in label.lower()][:6]
products = [{"label": p["title"], "href": f"/product/{p['slug']}"} for p in PRODUCTS if needle in str(p["title"]).lower()][:3]
return JSONResponse({"groups": [{"label": "Search suggestions", "items": [{"label": label, "href": f"/search?q={quote_plus(label)}"} for label in matched]}, {"label": "Products", "items": products}]})
@app.get("/search", response_class=HTMLResponse)
def search(request: Request, q: str = "") -> HTMLResponse:
needle = q.strip().lower()
matches = PRODUCTS if not needle or needle in {"deals", "appliances"} else [p for p in PRODUCTS if needle in json.dumps(p).lower()]
cards = "".join(product_card(product) for product in matches)
body = f'
'
# The account page must reflect the rotated session, not the anonymous
# one the request arrived with, so the shell is rendered from the new
# token rather than from ``request.cookies``.
account = account_backend.public_account(auth_services().resolve_session(new_token))
page = HTMLResponse(
document(
"Account created | Lowe's",
body,
cart_units_for_token(new_token),
account=account,
)
)
return set_session_cookie(page, new_token)
except Exception as exc:
_field, message = account_backend.friendly_error(exc)
body = f'
'),
token,
)
@app.post("/account/signout")
async def account_signout(request: Request) -> RedirectResponse:
"""Revoke the server-side session first, then drop the cookie.
The anonymous cart is deliberately not migrated: the revoked session's
owner digest keeps its rows, and the next request starts a fresh anonymous
session, which is what a real sign-out looks like from the browser.
"""
account_backend.sign_out(auth_services(), read_session_token(request))
return clear_session_cookie(RedirectResponse("/", status_code=303))
# ---------------------------------------------------------------------------
# password recovery
# ---------------------------------------------------------------------------
RESET_STEP_INTRO = (
"
Enter the email or reserved test phone number on your local account. "
"This clone answers the same way whether or not an account exists.
'
return set_session_cookie(
render(
request,
"Reset your password | Lowe's",
reset_request_form(identifier_raw, notice),
status_code=400,
),
token,
)
# The store's public message is identical for a known and an unknown
# identity. The sandbox block below is the one place they differ, and only
# while the local development helper is on: with
# ``LOWES_LOCAL_SANDBOX_HELP=0`` ``sandbox_code`` returns None for both and
# the two responses become byte-identical.
code = account_backend.sandbox_code(
auth_services(), token, purpose=account_backend.PURPOSE_PASSWORD_RESET
)
help_box = (
'
Local sandbox code: '
f'{escape(code)} This value comes from the local outbox '
"and was not sent externally.
"
if code
else '
No local sandbox code is '
"available to display. Nothing was sent to any external service.
'
)
account = account_backend.public_account(auth_services().resolve_session(new_token))
page = HTMLResponse(
document(
"Password updated | Lowe's",
body,
cart_units_for_token(new_token),
account=account,
)
)
return set_session_cookie(page, new_token)
@app.post("/checkout/place")
async def checkout_place(request: Request) -> HTMLResponse:
values = await form_values(request)
token, owner = ensured_owner(request)
cart = site_store.get_cart(owner)
try:
checkout_data = site_store.validate_checkout(values, cart=cart, scenario_ids=[item["id"] for item in site_store.payment_scenarios()])
# Binding the order to the account as well as to the session digest is
# what keeps it visible after a sign-out/sign-in rotates the session.
result = site_store.place_order(
owner, checkout_data, account_id=current_account_id(request)
)
if result["placed"]:
order = result["order"]
body = f'
Approved local simulation
Thanks, your offline order is recorded
Order {escape(order["order_number"])} totals ${site_store.money(order["total_cents"])}.
A simulated confirmation was queued in the local outbox; nothing was sent to Lowe\'s or an external provider.
'
response = render(request, "Order result | Lowe's", body)
except Exception as exc:
if isinstance(exc, site_store.CheckoutError):
message = " ".join(exc.errors.values())
else:
message = "The local checkout could not be completed."
response = render(request, "Checkout error | Lowe's", f'
" + fact_table(page.facts) + ""
if page.facts
else ""
)
+ landing_catalog(page)
+ ""
)
@app.get("/l/{path:path}", response_class=HTMLResponse)
def landing_route(request: Request, path: str) -> HTMLResponse:
page = landing.LANDING_PAGES.get("/l/" + path.rstrip("/"))
if page is None:
return not_found(request, "/l/" + path)
return render(request, page.title, landing_body(page))
# ---------------------------------------------------------------------------
# /ai — local shopping assistant
# ---------------------------------------------------------------------------
AI_STARTERS = (
"refrigerator",
"cordless drill",
"interior paint",
"ceiling fan",
"water heater",
"lawn mower",
)
@app.get("/ai", response_class=HTMLResponse)
def ai_assistant(request: Request, q: str = "") -> HTMLResponse:
question = q.strip()
starters = "".join(
f'{escape(term)}'
for term in AI_STARTERS
)
if question:
result = site_store.search(query=question, sort="relevance", page_size=6)
if result["products"]:
answer = (
f'
{int(result["total"])} item(s) in this '
f"clone's catalog match “{escape(question)}”. The ranking is the "
"same deterministic relevance score the search page uses.
“{escape(question)}” returned no rows. This assistant can only "
"answer from the frozen local catalog — it never calls a model, a "
"search service or any other network endpoint.
"
)
else:
answer = (
'
Ask about something in this catalog
'
"
Pick a starter above or type a product, brand or category.
A local, deterministic shopping assistant. It '
"answers only from this clone's frozen catalog, so the same question "
"always returns the same items.
"
+ sandbox_notice(
"No model, inference endpoint or third-party service is contacted. "
"The source /ai page answered Access Denied to the recorded "
"Playwright session, so this is not a reproduction of it."
)
+ ''
f'
{starters}
'
+ answer
+ ""
)
title = (
f"AI Assist: {question} | Lowe's" if question else "Lowe's AI Assist | Lowe's"
)
return render(request, title, body, query=question)
# ---------------------------------------------------------------------------
# /b/lowesbrands — brand directory
# ---------------------------------------------------------------------------
@app.get("/b/lowesbrands", response_class=HTMLResponse)
def brand_directory(request: Request, brand: str = "") -> HTMLResponse:
all_brands = site_store.brands()
counts = site_store.search(page_size=1)["facet_brands"]
selected = brand if brand in all_brands else ""
tiles = "".join(
f''
f"{escape(name)}"
f'{int(counts.get(name, 0))} items'
for name in all_brands
)
if selected:
result = site_store.search(brand_names=[selected], sort="top-sellers", page_size=12)
listing = (
'
Every brand below is invented for this offline '
"clone and deliberately names no real Lowe's vendor, so a brand page here "
"can never be mistaken for a captured one.
"
+ sandbox_notice(SOURCE_RESTRICTED_NOTE)
+ f'
{tiles}
'
+ listing
+ ""
)
title = (
f"{selected} | Lowe's Brands" if selected else "Lowe's Brands Directory | Lowe's"
)
return render(request, title, body)
# ---------------------------------------------------------------------------
# /diy-projects-and-ideas and /n/how-to/...
# ---------------------------------------------------------------------------
DIY_THEMES = (
(
"Outdoor cooking",
"Clean, season and store a grill so it lights first time next season.",
"/n/how-to/clean-and-maintain-your-grill-ht",
"Read the how-to",
),
(
"Family workshops",
"Free hands-on builds for the MyLowe's Rewards Kids Club.",
"/diy-projects-and-ideas/workshops",
"See workshops",
),
(
"Seasonal refresh",
"Room-by-room ideas that need paint, lighting and hardware only.",
"/l/fresh-projects-and-inspiration",
"Get inspired",
),
(
"Home maintenance",
"The seasonal checklist behind this clone's repeat-delivery categories.",
"/l/shop/home-maintenance",
"See the checklist",
),
(
"Window treatments",
"Measure an opening and configure a blind to it, priced server-side.",
"/configure/blinds/allen-roth-Cordless-Cellular-Shade/5015737843",
"Open the configurator",
),
(
"Paint projects",
"Sheens, primers and coverage for interior and exterior work.",
"/l/shop/online-paint-store",
"Visit the paint store",
),
)
@app.get("/diy-projects-and-ideas", response_class=HTMLResponse)
def diy_projects(request: Request) -> HTMLResponse:
cards = "".join(
''
f"
{escape(title)}
{escape(copy)}
"
f'{escape(cta)}'
""
for title, copy, href, cta in DIY_THEMES
)
body = (
''
+ breadcrumb_bar([("Home", "/"), ("DIY Projects & Ideas", None)])
+ '
Ideas & Inspiration
'
+ '
DIY Projects & Ideas
'
+ '
The project hub that sits above this clone\'s '
"how-to article, its family workshops page and its configurable window "
"treatments. Every card below opens a page this clone serves itself.
"
+ sandbox_notice(SOURCE_RESTRICTED_NOTE)
+ f'
{cards}
'
+ ""
)
return render(request, "DIY Projects & Ideas | Lowe's", body)
GRILL_HOW_TO = {
"intro": (
"A grill that is cleaned after the season lights faster, cooks more "
"evenly and lasts longer. This is the full sequence, from a burnt-on "
"grate to a covered grill ready for storage."
),
"time": "About 60 minutes, plus drying time",
"difficulty": "Beginner",
"steps": (
(
"Burn off the residue",
"Run the grill on high with the lid closed for 15 minutes so food "
"residue turns to ash, then turn it off and let it cool enough to "
"handle.",
),
(
"Brush the grates",
"Work along the bars, not across them, with a stiff grate brush. "
"Replace a brush as soon as bristles start to shed.",
),
(
"Empty the grease tray",
"Pull the tray and the catch cup, scrape them out and wash them. A "
"full tray is the most common cause of a flare-up.",
),
(
"Clean the burner tubes",
"Brush along the tubes so every port is open, and check that the "
"flame is blue and even when you relight.",
),
(
"Wash the exterior",
"Warm water and dish soap on the lid and cart, rinsed and dried. "
"Wipe stainless steel along the grain.",
),
(
"Season and cover",
"Coat the grates with a thin film of high-smoke-point oil, run the "
"grill for 15 minutes, let it cool and fit the cover.",
),
),
"supplies": (
"Grate brush or scraper",
"Bucket, warm water and dish soap",
"Non-abrasive cloths",
"High-smoke-point cooking oil",
"Replacement grease cups",
"A fitted grill cover",
),
}
@app.get("/n/how-to/{article}", response_class=HTMLResponse)
def how_to_article(request: Request, article: str) -> HTMLResponse:
slug = article.rstrip("/")
if not slug:
return not_found(request, "/n/how-to/")
# The captured inventory carries exactly one how-to path; anything else that
# matches the pattern gets the same structure with its own URL-derived title
# rather than a shared filler body.
is_grill = slug.startswith("clean-and-maintain-your-grill")
display = commerce.humanize(slug.removesuffix("-ht"))
heading = "How to Clean and Maintain Your Grill" if is_grill else f"How to {display}"
intro = GRILL_HOW_TO["intro"] if is_grill else (
f"A step-by-step local article for {display.lower()}. This clone ships "
"one fully written how-to; every other path in the family renders this "
"same structure from its own URL."
)
steps = "".join(
f"
{escape(title)}
{escape(copy)}
"
for title, copy in (
GRILL_HOW_TO["steps"] if is_grill else (("Plan the work", intro),)
)
)
supplies = "".join(
f"
{escape(item)}
"
for item in (GRILL_HOW_TO["supplies"] if is_grill else ("Project-specific supplies",))
)
related = site_store.search(
query="grill" if is_grill else "", category_ids=("outdoor-living",), page_size=4
)
body = (
''
+ breadcrumb_bar(
[
("Home", "/"),
("DIY Projects & Ideas", "/diy-projects-and-ideas"),
(heading, None),
]
)
+ '
How-To
'
+ f'
{escape(heading)}
'
+ f'
{escape(intro)}
'
+ sandbox_notice(SOURCE_RESTRICTED_NOTE)
+ fact_table(
(
("Time", str(GRILL_HOW_TO["time"]) if is_grill else "Varies"),
("Difficulty", str(GRILL_HOW_TO["difficulty"]) if is_grill else "Varies"),
("Steps", str(len(GRILL_HOW_TO["steps"]) if is_grill else 1)),
)
)
+ f'
This clone carries four synthetic stores. Clear the search to see "
"them all.
"
)
body = (
''
+ breadcrumb_bar([("Home", "/"), ("Find a Store", None)])
+ '
Store Finder
'
+ "
Find a Lowe's Store
"
+ '
These four stores are the ones the local pickup '
"selector and the sandbox checkout actually use. Searching filters them "
"on the server.
"
+ sandbox_notice(SOURCE_RESTRICTED_NOTE)
+ ''
f'
{len(matches)} of {len(rows)} stores
'
f'
{cards}
'
+ action_row(
(
("Full store directory", "/Lowes-Stores"),
("In-store services", "/l/about/store-services"),
)
)
+ ""
)
return render(request, "Find a Lowe's Store Near You | Lowe's", body)
# ---------------------------------------------------------------------------
# /weekly-ad
# ---------------------------------------------------------------------------
WEEKLY_AD_EVIDENCE_NOTE = (
"Evidence gap: the recorded Playwright replay of the source Weekly Ad only "
"ever captured a loading skeleton, so no source layout was observed for this "
"route at all. The circular below is built entirely from this clone's own "
"catalog savings."
)
@app.get("/weekly-ad", response_class=HTMLResponse)
def weekly_ad(request: Request, store: str = "") -> HTMLResponse:
stores = site_store.stores()
selected = next(
(row for row in stores if str(row["id"]) == store), stores[0] if stores else None
)
options = "".join(
f''
for row in stores
)
front = site_store.search(sort="savings", page_size=4)
inside = site_store.search(sort="savings", page_size=8, page=2)
body = (
''
+ breadcrumb_bar([("Home", "/"), ("Weekly Ad", None)])
+ '
Weekly Ad
'
+ '
This Week\'s Ad
'
+ '
Every offer below is computed from the local '
"catalog's own was-and-now prices, so the ad, the product card and the "
"cart all quote the same number.
"
+ sandbox_notice(WEEKLY_AD_EVIDENCE_NOTE)
+ ''
+ (
f'
Showing the ad for {escape(str(selected["name"]))},'
f' {escape(str(selected["city"]))}, {escape(str(selected["state"]))}.
'
+ catalog_grid(inside["products"])
+ ""
+ action_row(
(
("Coupons", "/l/savings/coupons"),
("Daily deals", "/l/savings/daily-deals"),
("Find a store", "/store/"),
)
)
+ ""
)
return render(request, "Weekly Ad | Lowe's", body)
# ---------------------------------------------------------------------------
# /mylowes/orders/checkorderstatus — guest order lookup
# ---------------------------------------------------------------------------
@app.get("/mylowes/orders/checkorderstatus", response_class=HTMLResponse)
def check_order_status(
request: Request, email: str = "", order_number: str = ""
) -> HTMLResponse:
result = ""
if email.strip() and order_number.strip():
order = site_store.get_order(order_number.strip().upper())
# The same wording covers "no such order" and "wrong email", so the form
# cannot be used to discover which order numbers exist.
if order and str(order["email"]).casefold() == email.strip().casefold():
items = "".join(
f'
Enter the order number from a local sandbox confirmation together with '
"the email address it was placed under. The lookup runs against this "
"clone's own database.
"
'"
+ result
+ '
Signed in? Your local order history is on '
'Order Status.
'
f'{cents(int(product["price_cents"]))}'
for role, product in package["members"]
)
hidden_ids = "".join(
f''
for product_id in package["product_ids"]
)
body = (
''
+ breadcrumb_bar(
[
("Home", "/"),
("Appliances", "/c/Appliances"),
(package["display_title"], None),
]
)
+ '
Appliance Suite '
+ escape(collection_id)
+ "
"
+ f'
{escape(package["display_title"])}
'
+ '
A four-piece suite assembled from this clone\'s '
"catalog. Adding the suite adds every member as a real cart line, priced "
"at each member's own catalog price.
Choose a size and the lift, opacity and colour '
"options. The quote is recalculated on the server from a frozen option "
"table, so a hand-edited query string cannot produce an unpriced "
"configuration.
'
""
)
return render(request, "Page not found | Lowe's", body, status_code=404)
@app.get("/{path:path}")
def informational(request: Request, path: str) -> Response:
target = LEGACY_REDIRECTS.get(path.strip("/"))
if target:
# A pre-inventory alias keeps working, but the source-compatible path is
# the one canonical URL from here on.
return RedirectResponse(target, status_code=308)
return not_found(request, "/" + path)