-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoauth.py
80 lines (67 loc) · 1.81 KB
/
noauth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from flask import Blueprint, render_template, request, redirect, url_for
from flask_login import current_user
from aflat.data import (
comments_data,
popular_data,
painting_data,
paintings_data,
get_stonk,
paintings_count_data,
)
noauth = Blueprint("main", __name__)
@noauth.route("/")
@noauth.route("/home")
def index():
if "page" not in request.args:
return render_template(
"index.html",
page=1,
stonk=get_stonk,
popular=popular_data(),
paintings=paintings_data(),
title="Home",
)
try:
page = int(request.args.get("page"))
except:
return render_template(
"index.html",
page=1,
stonk=get_stonk,
popular=popular_data(),
paintings=paintings_data(),
title="Home",
)
count_pages = int(paintings_count_data() / 5)
if page > count_pages:
page = count_pages
return render_template(
"index.html",
page=page + 1,
stonk=get_stonk,
popular=popular_data(),
paintings=paintings_data(page),
title="Home",
)
@noauth.route("/painting")
def painting():
login = current_user.is_authenticated
if "id" not in request.args:
return redirect(url_for("main.index"))
try:
id_ = int(request.args.get("id"))
except:
return redirect(url_for("main.index"))
return render_template(
"painting.html",
popular=popular_data(),
login=login,
data=painting_data(id_),
comments=comments_data(id_),
)
@noauth.route("/about")
def about():
return render_template("about.html", title="About")
@noauth.route("/account")
def account():
return render_template("about.html", title="Account")