easyctf-2017/server/api/admin.py

26 lines
723 B
Python
Raw Normal View History

2016-01-03 03:15:23 +00:00
from flask import Blueprint, jsonify
2016-01-07 00:23:43 +00:00
from decorators import admins_only, api_wrapper
2016-01-03 03:15:23 +00:00
from models import db, Problems, Files
2015-12-24 03:51:42 +00:00
2016-01-07 00:23:43 +00:00
import json
2015-12-27 00:19:31 +00:00
blueprint = Blueprint("admin", __name__)
2016-01-03 03:15:23 +00:00
2016-01-12 03:54:26 +00:00
@blueprint.route("/problems/list", methods=["GET"])
2016-01-07 00:23:43 +00:00
@api_wrapper
2016-01-03 03:15:23 +00:00
@admins_only
def problem_data():
2016-01-07 00:23:43 +00:00
problems = Problems.query.order_by(Problems.value).all()
problems_return = [ ]
for problem in problems:
problems_return.append({
"pid": problem.pid,
"name": problem.name,
"category": problem.category,
"description": problem.description,
"hint": problem.hint,
"value": problem.value,
"threshold": problem.threshold,
"weightmap": json.loads(problem.weightmap)
})
return { "success": 1, "problems": problems_return }