forked from DestructiveVoice/DestructiveFarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
33 lines (24 loc) · 958 Bytes
/
api.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
import time
from flask import request, jsonify
from server import app, auth, database, reloader
from server.models import FlagStatus
from server.spam import is_spam_flag
@app.route('/api/get_config')
@auth.api_auth_required
def get_config():
config = reloader.get_config()
return jsonify({key: value for key, value in config.items()
if 'PASSWORD' not in key and 'TOKEN' not in key})
@app.route('/api/post_flags', methods=['POST'])
@auth.api_auth_required
def post_flags():
flags = request.get_json()
flags = [item for item in flags if not is_spam_flag(item['flag'])]
cur_time = round(time.time())
rows = [(item['flag'], item['sploit'], item['team'], cur_time, FlagStatus.QUEUED.name)
for item in flags]
db = database.get()
db.executemany("INSERT OR IGNORE INTO flags (flag, sploit, team, time, status) "
"VALUES (?, ?, ?, ?, ?)", rows)
db.commit()
return ''