45 lines
856 B
Python
45 lines
856 B
Python
from datetime import datetime
|
|
from secrets import token_hex
|
|
|
|
from flask import Flask, render_template
|
|
|
|
from pynyaata.forms import SearchForm
|
|
from pynyaata.translations import current_lang, i18n
|
|
|
|
app = Flask(__name__)
|
|
app.config["SECRET_KEY"] = token_hex()
|
|
|
|
|
|
@app.context_processor
|
|
def utility_processor():
|
|
current_date = datetime.now()
|
|
apocalypse_left = (
|
|
datetime(current_date.year + 5 - (current_date.year % 5), 6, 4, 0, 1)
|
|
- current_date
|
|
)
|
|
|
|
return dict(
|
|
_=i18n,
|
|
current_lang=current_lang(),
|
|
search_form=SearchForm(),
|
|
apocalypse_left=apocalypse_left,
|
|
)
|
|
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return render_template("index.html.j2")
|
|
|
|
|
|
@app.route("/search")
|
|
def search():
|
|
return render_template("search.html.j2")
|
|
|
|
|
|
def run():
|
|
app.run("0.0.0.0")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run()
|