diff --git a/app/main.py b/app/main.py deleted file mode 100644 index b896c4f..0000000 --- a/app/main.py +++ /dev/null @@ -1,17 +0,0 @@ -from flask import Flask, render_template - -app = Flask( - __name__, - template_folder="templates", - static_folder="resources", - static_url_path="/resources", -) - - -@app.route("/") -def index(): - return render_template("index.html") - - -if __name__ == "__main__": - app.run(debug=True) diff --git a/pyproject.toml b/pyproject.toml index 150616c..f1c196e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,4 +6,5 @@ readme = "README.md" requires-python = ">=3.13" dependencies = [ "flask>=3.1.3", + "uvicorn>=0.47.0", ] diff --git a/app/resources/videos/.gitkeep b/src/__init__.py similarity index 100% rename from app/resources/videos/.gitkeep rename to src/__init__.py diff --git a/src/i18n.py b/src/i18n.py new file mode 100644 index 0000000..18ea596 --- /dev/null +++ b/src/i18n.py @@ -0,0 +1,13 @@ +from translations import en_strings, it_strings + +_LANGUAGES: dict[str, dict] = { + "it": it_strings, + "en": en_strings, +} + +DEFAULT_LANG = "it" +SUPPORTED_LANGS = list(_LANGUAGES.keys()) + + +def get_translations(lang_code: str) -> dict: + return _LANGUAGES.get(lang_code, _LANGUAGES[DEFAULT_LANG]) diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..d775956 --- /dev/null +++ b/src/main.py @@ -0,0 +1,22 @@ +from flask import Flask, render_template, request +from src.i18n import get_translations, SUPPORTED_LANGS + +app = Flask( + __name__, + template_folder="templates", + static_folder="resources", + static_url_path="/resources", +) + + +@app.route("/") +def index(): + lang = request.args.get("lang", "it") + if lang not in SUPPORTED_LANGS: + lang = "it" + t = get_translations(lang) + return render_template("index.html", t=t, lang=lang, supported_langs=SUPPORTED_LANGS) + + +if __name__ == "__main__": + app.run(debug=False) diff --git a/app/resources/css/style.css b/src/resources/css/style.css similarity index 80% rename from app/resources/css/style.css rename to src/resources/css/style.css index d608501..06844aa 100644 --- a/app/resources/css/style.css +++ b/src/resources/css/style.css @@ -4,6 +4,39 @@ padding: 0; } +.lang-switcher { + position: fixed; + top: 0.75rem; + right: 1rem; + display: flex; + gap: 0.4rem; + z-index: 10; +} + +.lang-btn { + padding: 0.25rem 0.6rem; + border-radius: 4px; + font-family: inherit; + font-size: 0.75rem; + font-weight: 600; + letter-spacing: 0.05em; + text-decoration: none; + background: rgba(255, 248, 220, 0.75); + color: #3b2a0e; + cursor: pointer; + transition: background 0.15s; +} + +.lang-btn:hover { + background: rgba(255, 248, 220, 0.95); +} + +.lang-btn--active { + background: rgba(107, 90, 42, 0.85); + color: #fdf5e0; + cursor: default; +} + body { font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; diff --git a/app/resources/main.jpg b/src/resources/main.jpg similarity index 100% rename from app/resources/main.jpg rename to src/resources/main.jpg diff --git a/src/resources/videos/.gitkeep b/src/resources/videos/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/index.html b/src/templates/index.html similarity index 74% rename from app/templates/index.html rename to src/templates/index.html index 2dbe6de..19c4325 100644 --- a/app/templates/index.html +++ b/src/templates/index.html @@ -1,5 +1,5 @@ - +
@@ -10,33 +10,43 @@ + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vehicula arcu vel ligula fermentum.
+{{ t.card1_text }}
Pellentesque habitant morbi tristique senectus et netus malesuada fames ac turpis egestas.
+{{ t.card2_text }}
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae.
+{{ t.card3_text }}