Files
bennyshouse.net/app.py

102 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# app.py
from __future__ import annotations
import os
from datetime import datetime
from flask import Flask, render_template, url_for, jsonify, Response
app = Flask(__name__, static_folder="static", template_folder="templates")
app.secret_key = os.getenv("APP_SECRET_KEY", "dev")
CONTACT = {
"name": os.getenv("BH_CONTACT_NAME", "Benjamin Mosley"),
"title": os.getenv("BH_CONTACT_TITLE", "E-Commerce Manager, United Supermarkets"),
"email": os.getenv("BH_CONTACT_EMAIL", "ben@bennyshouse.net"),
"phone": os.getenv("BH_CONTACT_PHONE", "(806) 655 2300"),
"city": os.getenv("BH_CONTACT_CITY", "Canyon / Amarillo / Borger / Remote"),
"cal": os.getenv("BH_CONTACT_CAL", "https://calendly.com/bennyshouse24/30min"),
"link": os.getenv("BH_CONTACT_LINK", "https://www.linkedin.com/in/benjamin-mosley-849643329/"),
"site": os.getenv("BH_CONTACT_SITE", "https://bennyshouse.net"),
"hours": os.getenv("BH_CONTACT_HOURS", "MonFri, 9a5p CT"),
}
BRAND = "Bennys House"
TAGLINE = "Fast to prototype. Safe to scale."
@app.route("/")
def home():
hero_imgs = [
url_for("static", filename="IMG_2153.jpeg"),
url_for("static", filename="IMG_2149.jpeg"),
url_for("static", filename="IMG_2158.jpeg"),
]
return render_template(
"index.html",
brand=BRAND,
tagline=TAGLINE,
contact=CONTACT,
hero_imgs=hero_imgs,
year=datetime.now().year,
)
@app.route("/about")
def about_page():
return render_template(
"about.html",
brand=BRAND,
tagline=TAGLINE,
contact=CONTACT,
year=datetime.now().year,
)
@app.route("/services")
def services_page():
return render_template(
"services.html",
brand=BRAND,
tagline=TAGLINE,
contact=CONTACT,
year=datetime.now().year,
)
@app.route("/contact")
def contact_page():
return render_template(
"contact.html",
brand=BRAND,
tagline=TAGLINE,
contact=CONTACT,
year=datetime.now().year,
)
@app.route("/api/contact")
def contact_json():
return jsonify(CONTACT)
@app.route("/benjamin.vcf")
def vcard_download():
v = _build_vcard(CONTACT)
return Response(
v,
mimetype="text/vcard; charset=utf-8",
headers={"Content-Disposition": "attachment; filename=benjamin-mosley.vcf"},
)
def _build_vcard(c: dict) -> str:
lines = [
"BEGIN:VCARD",
"VERSION:3.0",
f"FN:{c['name']}",
f"TITLE:{c['title']}",
f"EMAIL;TYPE=INTERNET:{c['email']}",
f"TEL;TYPE=CELL:{c['phone']}",
f"ADR;TYPE=WORK:;;{c['city']};;;",
f"URL:{c['site']}",
f"X-LINKEDIN:{c['link']}",
"END:VCARD",
]
return "\r\n".join(lines) + "\r\n"
if __name__ == "__main__":
app.run(debug=True)