"""
return layout(request, "Furniture with Deluxe delivery and unpacking", body, active="help", retail_department="Furniture with Deluxe delivery and unpacking")
if service == "fitness-equipment":
categories = (
("treadmills", "Treadmills"),
("bikes", "Exercise Bikes"),
("ellipticals", "Ellipticals"),
("rowers", "Rowers"),
("benches", "Benches"),
("machines", "Machines and Towers"),
)
category_links = "".join(
f''
f'{label}'
for slug, label in categories
)
rail_links = "".join(
f'{label}'
for slug, label in categories
)
rail = f"""Home ServicesFitness EquipmentFurnitureGrillsTelevisionsEligible for Professional Assembly{rail_links}ResourcesHelp and Customer ServiceDepartmentFitness equipment with professional assembly"""
selected = next((item for item in categories if item[0] == q.get("category")), None)
if selected:
category_slug, category_label = selected
body = f"""
"""
return layout(
request,
f"{category_label} with professional assembly",
body,
active="home",
retail_department="Fitness equipment with professional assembly",
)
body = f"""
"""
return layout(
request,
"Fitness equipment with professional assembly",
body,
active="home",
retail_department="Fitness equipment with professional assembly",
)
zip_code = q.get("zip", "")
verified = q.get("verified") == "1"
rating = float(q.get("rating", "0") or 0)
price = int(q.get("price", "0") or 0)
sort = q.get("sort", "recommended")
with SERVICES.auth.connect() as connection:
services = db.rows(connection.execute("SELECT * FROM an_services ORDER BY name").fetchall())
providers = db.rows(connection.execute("SELECT * FROM an_providers").fetchall())
if query and not service:
match = next((item for item in services if query in item["name"].lower() or query in item["summary"].lower()), None)
service = match["slug"] if match else ""
for item in providers:
item["services"] = json.loads(item["services_json"])
item["distance"] = db.distance(zip_code, item["zip"]) if zip_code else 0
if service:
providers = [item for item in providers if service in item["services"]]
if zip_code:
providers = [item for item in providers if item["distance"] <= item["radius_miles"]]
if verified:
providers = [item for item in providers if item["verified"]]
if rating:
providers = [item for item in providers if item["rating"] >= rating]
if price:
providers = [item for item in providers if item["price_level"] <= price]
keys = {"rating": lambda x: -x["rating"], "reviews": lambda x: -x["review_count"], "distance": lambda x: x["distance"], "price": lambda x: x["price_level"]}
providers.sort(key=keys.get(sort, lambda x: (-x["verified"], -x["rating"], x["response_minutes"])))
options = "".join(f"" for item in services)
cards = "".join(provider_card(item) for item in providers)
empty = "" if providers else "
No pros match those filters
Try a nearby ZIP, lower rating threshold or clear filters. Your project details are unchanged.
"""
return layout(request, "Televisions with Delivery and unpacking", body, active="help", retail_department="Televisions with Delivery and unpacking")
with SERVICES.auth.connect() as connection:
service = db.row(connection.execute("SELECT * FROM an_services WHERE slug=?", (slug,)).fetchone())
providers = db.rows(connection.execute("SELECT * FROM an_providers").fetchall())
if not service:
return layout(request, "Service not found", "
Service not found
Browse services")
providers = [item for item in providers if slug in json.loads(item["services_json"])][:3]
body = f"""
{esc(service['category'])}
{esc(service['name'])}
{esc(service['description'])}
Typical local demo range{money(service['price_low'])}–{money(service['price_high'])}{esc(service['unit'])}
Tell us about the workAnswer project-specific questions.
Compare local quotesReview price, timing and provider details.
Book in the sandboxNo real provider or payment is involved.
Featured {esc(service['name'])} pros
{''.join(provider_card(item) for item in providers)}
"""
return layout(request, service["name"], body, active="services")
@app.get("/pros/{slug}")
def provider_detail(slug: str, request: Request) -> HTMLResponse:
with SERVICES.auth.connect() as connection:
provider = db.row(connection.execute("SELECT * FROM an_providers WHERE slug=?", (slug,)).fetchone())
if not provider:
return layout(request, "Provider not found", "
Provider not found
Find another pro")
portfolio = db.rows(connection.execute("SELECT * FROM an_portfolio WHERE provider_id=?", (provider["provider_id"],)).fetchall())
reviews = db.rows(connection.execute("SELECT * FROM an_public_reviews WHERE provider_id=? AND public=1 ORDER BY created_at DESC", (provider["provider_id"],)).fetchall())
services = json.loads(provider["services_json"])
availability = json.loads(provider["availability_json"])
gallery = "".join(f"Project photo
{esc(item['title'])}
{esc(item['caption'])}
" for item in portfolio)
review_html = "".join(f"
{'★'*item['rating']}{'☆'*(5-item['rating'])}
{esc(item['body'])}
{esc(item['author'])} · {esc(item['service_type'])}" for item in reviews)
slots = "".join(f"" for slot in availability) or ""
service_opts = "".join(f"" for s in services)
body = f"""
{''.join(x[0] for x in provider['name'].split()[:2])}
Screened local demo profile
{esc(provider['name'])}
★ {provider['rating']:.1f} · {provider['review_count']} reviews · {provider['years_in_business']} years in business
✓ Identity screened{'Licensed' if provider['licensed'] else ''}Insured
{esc(provider['bio'])}
{esc(provider['city'])}, {esc(provider['state'])} · {provider['radius_miles']}-mile service area · responds in about {provider['response_minutes']} min
Price level: {'$'*provider['price_level']} · final scope and synthetic quote are shown before any local booking.
Project portfolio
Synthetic examples
{gallery}
Homeowner reviews
Public local-demo reviews only
{review_html or '
No public reviews yet.
'}
Availability
Choose a preferred time
Selection is carried into a local request and can be changed later.
"""
return layout(request, provider["name"], body, active="services")
def auth_page(request: Request, mode: str) -> HTMLResponse:
configs = {
"register": ("Create your account", "Save providers and manage local projects.", "", "Create account", "Already a member? Log in"),
"login": ("Welcome back", "Continue your synthetic home project.", "", "Log in", "Forgot password? · Create account"),
"verify": ("Verify locally", "Use the code displayed in the local outbox below.", "
Loading local code…
", "Verify account", "No email is sent outside this site."),
"forgot": ("Reset your password", "A reset code will be written to this session's local outbox.", "", "Create local reset code", "Return to login"),
"reset": ("Choose a new password", "Enter the code from the local outbox.", "
Loading local code…
", "Update password", "No external delivery is used."),
}
heading, intro, fields, button, foot = configs[mode]
body = f"
"""
return layout(request, "My projects", body, active="projects")
@app.get("/saved")
def saved(request: Request) -> HTMLResponse:
c = current(request)
if not c.account_id:
return RedirectResponse("/login?next=/saved", 303)
return layout(request, "Saved services", "
Your shortlist
Saved service options
Compare synthetic technician profiles before booking.
Find more servicesLoading saved services…")
@app.get("/settings")
def settings_page(request: Request) -> HTMLResponse:
c = current(request)
if not c.account_id:
return RedirectResponse("/login?next=/settings", 303)
body = """
Account controls
Privacy, security & notifications
All settings affect only this local WebsiteBench account.
No external Amazon session is visible or affected.
"""
return layout(request, "Privacy and account settings", body)
@app.get("/projects/{project_id}")
def project_page(project_id: str, request: Request) -> HTMLResponse:
c = current(request)
if not c.account_id:
return RedirectResponse(f"/login?next=/projects/{project_id}", 303)
body = f"""← All appointments
Local in-home service
Choose a package, date and technician
Every action is contained in this synthetic WebsiteBench sandbox.
Loading appointment…
"""
return layout(request, "Manage service appointment", body, active="projects")
@app.get("/provider/dashboard")
def provider_dashboard(request: Request) -> HTMLResponse:
c = current(request)
if not c.account_id:
return RedirectResponse("/login?next=/provider/dashboard", 303)
body = "
Technician workspace · synthetic
HomeTech assignments
Review local-demo appointments and update arrival/job state without contacting a real customer.
Customer viewLoading local assignments…"
return layout(request, "Provider lead management", body, active="projects")
@app.get("/help")
def help_page(request: Request) -> HTMLResponse:
query = request.query_params.get("q", "").strip()
topics = (
"All Help Topics", "Shipping and Delivery", "Returns and Refunds",
"Payment, Pricing and Promotions", "Security and Privacy", "Ordering",
"Managing Your Account", "Gifts, Gift Cards and Registries", "Site Features",
"Amazon Global Store", "Amazon Business Help", "Digital Services and Device Support",
"Author Publisher & Vendor Guides", "Large Items and Heavy-Bulky Services",
"Amazon Health Help Center", "Amazon Fresh and Groceries on Amazon",
"Shipping and Delivery with Amazon Logistics", "Amazon Now", "Amazon Physical Stores",
)
sections = (
("about-large-and-bulky-items", "About Large and Bulky Items", (
"Buying Large and Bulky Items", "Shipping Restrictions for Large Items",
"Prepare for Your Service Appointment or Large Item Delivery")),
("large-items-delivery", "Large Items Delivery", (
"Special Delivery Options for Large and Bulky Items", "Change Your Scheduled Delivery Date and Time",
"Buy Online, Pick Up in Store", "Ship Your Large Item to a Local Store for Assembly or Installation",
"More about Large Items Delivery")),
("home-services", "Home Services & Service Provider Licensing", (
"Installation, Assembly, and Haul-Away Services", "Reschedule Your Service Appointment",
"More about Home Services & Service Provider Licensing")),
("large-appliances", "Large Appliances", (
"Buying Large Appliances on Amazon.com", "Cooking Ranges (Electric)", "Cooking Ranges (Gas)",
"Dishwashers", "Dryers (Electric)", "Dryers (Gas)")),
)
narrow_topic_lines = {
"Shipping and Delivery": ("Shipping and", "Delivery"),
"Returns and Refunds": ("Returns and", "Refunds"),
"Payment, Pricing and Promotions": ("Payment,", "Pricing and", "Promotions"),
"Security and Privacy": ("Security and", "Privacy"),
"Managing Your Account": ("Managing", "Your", "Account"),
"Gifts, Gift Cards and Registries": ("Gifts, Gift", "Cards and", "Registries"),
"Amazon Global Store": ("Amazon", "Global", "Store"),
"Amazon Business Help": ("Amazon", "Business", "Help"),
"Digital Services and Device Support": ("Digital", "Services", "and Device", "Support"),
"Author Publisher & Vendor Guides": ("Author", "Publisher &", "Vendor", "Guides"),
}
def topic_label(text: str) -> str:
lines = narrow_topic_lines.get(text)
return "".join(f'{esc(line)}' for line in lines) if lines else esc(text)
rail = "".join(
f'{topic_label(text)}'
if text == "Large Items and Heavy-Bulky Services"
else f'{topic_label(text)}'
for text in topics
)
def help_link(slug: str, link: str) -> str:
marker = '›' if link.startswith("More about") else ""
return f'{marker}{esc(link)}'
rows = "".join(
f'
{esc(label)}
'
+ "".join(help_link(slug, link) for link in links)
+ "
"
for slug, label, links in sections
)
result = f'