|  | from flask import Flask, render_template, redirect, request
from time import time
from urllib.parse import urlparse
from markdown2 import markdown
import json
import os.path
app = Flask(
    __name__,
    static_url_path='',
    static_folder='static/',
    template_folder='templates/'
)
@app.route('/')
def index():
    return render_template("index.html", nightly=False)
@app.route('/nightly')
def nightly():
    return render_template("index.html", nightly=True)
@app.route('/agegate')
def agegate():
    url = request.args.get("to", default="/")
    return render_template("age-gate.html", url=url)
@app.route('/accept')
def accept():
    url = request.args.get("url", default=None)
    print(urlparse(url).netloc)
    if urlparse(url).netloc and urlparse(url).netloc[-9:] != "crux.sexy":
        print("oops")
        url = "/"
    if not url:
        url = "/"
    res = redirect(url, 307)
    res.set_cookie("agegate", "true", time() + 60*60*24*365, domain="crux.sexy")
    return res
@app.route('/changelog')
def changelog():
    game_names = ["stroll", "feast", "gorge", "satiate"]
    games = []
    for game in game_names:
        data = json.load(open("{0}/changelog.json".format(game)))
        keys = sorted(data.keys())[::-1]
        versions = []
        for key in keys:
            versions.append({"version": key, "changes": markdown(data[key])})
        games.append({"name": game, "versions": versions})
    return render_template("changelog.html", games=games)
@app.route('/commits')
def commits():
    game_names = ["stroll", "feast", "gorge", "satiate"]
    games = []
    for game in game_names:
        data = json.load(open("nightly/{0}/nightly.json".format(game)))
        games.append({"name": game, "commits": data})
    return render_template("commits.html", games=games)
if __name__ == "__main__":
    app.run(debug=True, host='0.0.0.0', port=5002)
 |