示例#1
0
文件: command_r.py 项目: Vorkits/api
def delete():
    form = dict(request.form)
    id = form.get('id')

    if id:
        return Command_base().delete_command(id)
    else:
        return {'status': 'no args'}, 401
示例#2
0
文件: command_r.py 项目: Vorkits/api
def get_city():
    form = dict(request.args)
    city = form.get('city')

    if city:
        return Command_base().get_by_city(city)
    else:
        return {'status': 'no args'}, 401
示例#3
0
文件: command_r.py 项目: Vorkits/api
def get():
    form = dict(request.args)
    id = form.get('id')

    if id:
        return Command_base().get_command(id)
    else:
        return {'status': 'no args'}, 401
示例#4
0
文件: command_r.py 项目: Vorkits/api
def set_field():
    form = dict(request.args)
    id = form.get('id')
    field = form.get('field')
    value = form.get('value')
    if value and field and id:
        return Command_base().set_field(id, field, value)
    else:
        return {'status': 'no args'}, 401
示例#5
0
文件: command_r.py 项目: Vorkits/api
def create():
    form = dict(request.form)
    player1 = form.get('player1')
    player2 = form.get('player2')
    name = form.get('name')
    if player1 and player2 and name:
        return Command_base().create_command(player1, player2, name)
    else:
        return {'status': 'no args'}, 401
示例#6
0
文件: tour_base.py 项目: Vorkits/api
 def finish_t(self, tornament_id, winner):
     db = self.db
     data = db.child('tournaments').child(tornament_id).get().val()
     w_id = winner
     winner = Command_base().get_command(winner)['data']
     data['status'] = 'end'
     data['winner'] = {
         'id': w_id,
         'name': winner['name'],
         'photo': winner['photo']
     }
     data = db.child('tournaments').child(tornament_id).set(data)
     return {'status': 'success', 'data': dict(data)}
示例#7
0
文件: command_r.py 项目: Vorkits/api
def upload_photo():
    if request.files:
        image = request.files[list(request.files.keys())[0]]
        print(UPLOADS_PATH)
        id = list(request.files.keys())[0]
        image.save(UPLOADS_PATH)
        img = Image.open(UPLOADS_PATH).resize((400, 400))  # (x,y) pixels
        uid = uuid.uuid4().hex
        img.convert("RGB").save(f'{uid}.jpg')
        os.remove(UPLOADS_PATH)
        return Command_base().photo(id, f'{uid}.jpg')
    else:
        print('non args')
        return {'status': 'error', 'desc': 'non args'}, 401
示例#8
0
文件: user_r.py 项目: Vorkits/api
def get_commands():
    form = dict(request.form)
    id = form.get('id')

    if id:
        r_data = {}
        try:
            data = f.get_user(id)['commands']
        except:
            data = {}

        r_data = Command_base().get_commands(list(data.keys()))
        return r_data
    else:
        print('non args')
        return {'status': 'error'}, 401
示例#9
0
def get_command_match():
    try:
        form=dict(request.form)
        id=form.get('id')
    
        if id:
        
            data=Command_base().get_command(id)['data']
            
            
            return {'status':'success','data':data['matches']},200
        else:
            print('non args')
            return{'status':'error'},401
    except Exception as e:
        print('non args')
        return{'status':str(e)},401