|
|
@ -9,6 +9,18 @@ from datetime import datetime |
|
|
|
from dateutil.tz import tzlocal |
|
|
|
import html2text |
|
|
|
from config import C |
|
|
|
WRONG_ANS_HTML = '''<html> |
|
|
|
<head> |
|
|
|
<meta charset='UTF-8'> |
|
|
|
<meta name='viewport' content='width=device-width initial-scale=1'> |
|
|
|
<title>错误</title> |
|
|
|
</head> |
|
|
|
<body> |
|
|
|
<h1>验证问题回答错误</h1> |
|
|
|
<a href="##" onclick="window.history.back()">回退</a> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
''' |
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
app.config.from_object('config.C') |
|
|
@ -99,18 +111,7 @@ def new_one(): |
|
|
|
|
|
|
|
for name, ques, hint, ans in C.verify: |
|
|
|
if request.form.get(name) != ans: |
|
|
|
return '''<html> |
|
|
|
<head> |
|
|
|
<meta charset='UTF-8'> |
|
|
|
<meta name='viewport' content='width=device-width initial-scale=1'> |
|
|
|
<title>错误</title> |
|
|
|
</head> |
|
|
|
<body> |
|
|
|
<h1>验证问题回答错误</h1> |
|
|
|
<a href="##" onclick="window.history.back()">回退</a> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
''', 401 |
|
|
|
return WRONG_ANS_HTML, 401 |
|
|
|
|
|
|
|
if not content or len(content)>4000: abort(422) |
|
|
|
if private and len(private)>1000: abort(422) |
|
|
@ -134,6 +135,18 @@ def new_one(): |
|
|
|
|
|
|
|
return redirect(".") |
|
|
|
|
|
|
|
@app.route('/ordinary/judge', methods=['POST']) |
|
|
|
@limiter.limit("10 / hour; 1 / 2 second") |
|
|
|
def judge(): |
|
|
|
|
|
|
|
group = request.form.get('groupType') |
|
|
|
|
|
|
|
for name, ques, hint, ans in C.verify: |
|
|
|
if request.form.get(name) != ans: |
|
|
|
return WRONG_ANS_HTML, 401 |
|
|
|
|
|
|
|
return redirect(C.groups.get(group)) |
|
|
|
|
|
|
|
@limiter.limit("100 / hour; 2 / second") |
|
|
|
@app.route('/ordinary/<int:toot>/comments') |
|
|
|
def get_comments(toot): |
|
|
|