|
|
@ -1,7 +1,9 @@ |
|
|
|
import argparse |
|
|
|
import argparse |
|
|
|
|
|
|
|
import base64 |
|
|
|
import json |
|
|
|
import json |
|
|
|
import os |
|
|
|
import os |
|
|
|
from getpass import getpass |
|
|
|
from getpass import getpass |
|
|
|
|
|
|
|
from pathlib import Path |
|
|
|
from random import randint |
|
|
|
from random import randint |
|
|
|
import sh |
|
|
|
import sh |
|
|
|
from flask import Flask, request, jsonify |
|
|
|
from flask import Flask, request, jsonify |
|
|
@ -89,6 +91,28 @@ def room(rid): |
|
|
|
return jsonify({'rid': r.room_id, "can_modify": False}) |
|
|
|
return jsonify({'rid': r.room_id, "can_modify": False}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/api/upload', methods=('POST',)) |
|
|
|
|
|
|
|
@jwt_required |
|
|
|
|
|
|
|
def upload_file(): |
|
|
|
|
|
|
|
file = request.json.get('file') |
|
|
|
|
|
|
|
file_name = request.json.get('file_name') |
|
|
|
|
|
|
|
file_content = base64.b64decode(file) |
|
|
|
|
|
|
|
with open("static/{}".format(file_name), "wb+") as f: |
|
|
|
|
|
|
|
f.write(file_content) |
|
|
|
|
|
|
|
return "ok" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/api/files') |
|
|
|
|
|
|
|
@jwt_required |
|
|
|
|
|
|
|
def get_file(): |
|
|
|
|
|
|
|
p = Path("./static") |
|
|
|
|
|
|
|
files = [] |
|
|
|
|
|
|
|
for i in p.glob("*.*"): |
|
|
|
|
|
|
|
files.append(i.name) |
|
|
|
|
|
|
|
return jsonify(files) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/api/create/room', methods=['POST']) |
|
|
|
@app.route('/api/create/room', methods=['POST']) |
|
|
|
@jwt_required |
|
|
|
@jwt_required |
|
|
|
def create_room(): |
|
|
|
def create_room(): |
|
|
@ -120,7 +144,7 @@ def create_room(): |
|
|
|
have_room = False |
|
|
|
have_room = False |
|
|
|
room.ridn = ridn |
|
|
|
room.ridn = ridn |
|
|
|
room.save() |
|
|
|
room.save() |
|
|
|
return jsonify({"msg": "seccess", "ridn": ridn}), 00 |
|
|
|
return jsonify({"msg": "seccess", "ridn": ridn}), 200 |
|
|
|
else: |
|
|
|
else: |
|
|
|
return jsonify({"msg": "You don't have a this access"}), 403 |
|
|
|
return jsonify({"msg": "You don't have a this access"}), 403 |
|
|
|
|
|
|
|
|
|
|
|