[feat/flask] Small fixes and maintenance
- Fixed encoding error when reading locale.ini - Added redirect from "/" route to "/en" route - Added ifmain to app.py to fix Flask console error - Added .gitignore for Flask - Added requirements.txt
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
.idea/
|
||||
.vscode/
|
||||
.venv*/
|
||||
venv*/
|
||||
__pycache__/
|
||||
dist/
|
||||
.coverage*
|
||||
htmlcov/
|
||||
.tox/
|
||||
docs/_build/
|
13
app.py
13
app.py
@@ -1,13 +1,19 @@
|
||||
from flask import Flask, render_template, request, url_for
|
||||
from flask import Flask, render_template, request, url_for, redirect
|
||||
from datetime import date
|
||||
from configparser import ConfigParser
|
||||
|
||||
locale = ConfigParser()
|
||||
locale.read('locale.ini')
|
||||
with open('locale.ini', encoding='utf-8') as f:
|
||||
locale.read_file(f)
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
print(locale)
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return redirect(url_for("index", lang="en"))
|
||||
|
||||
@app.route("/<lang>")
|
||||
def index(lang):
|
||||
return render_template(f'{lang}.html', locale=locale, lang=lang, year=date.today().year) # TODO: Check for vulnerability
|
||||
@@ -16,4 +22,5 @@ def index(lang):
|
||||
def download_page(lang):
|
||||
return render_template('tmpl/download.htm', locale=locale, lang=lang)
|
||||
|
||||
app.run(host="0.0.0.0", debug=True)
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", debug=True)
|
||||
|
8
requirements.txt
Normal file
8
requirements.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
blinker==1.9.0
|
||||
click==8.1.8
|
||||
colorama==0.4.6
|
||||
Flask==3.1.0
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.6
|
||||
MarkupSafe==3.0.2
|
||||
Werkzeug==3.1.3
|
Reference in New Issue
Block a user