def schedule_posting(received): user = received['user'] img = received['img'] binary_image = received['binary_image'] subtitle = received['subtitle'] location = received['location'] instagram = received['instagram'] date = received['date'] date_image = f'{datetime.now().year}-' + f'{datetime.now().month}-' + f'{datetime.now().day}' BASE_DIR = os.path.dirname(os.path.abspath(__file__)) img_path = os.path.join(BASE_DIR, f"uploads/{date_image}-{user}-{img}") if date < datetime.now(): return 'Horario invalido' conn = Connector() result = conn.add_schedule(img_path, subtitle, location, instagram, date, user) if result['status'] != None: # Salvando a imagem na pasta upload com o nome padrão : yyyy-mm-dd-email-name.jpeg with open((img_path), 'wb') as f: f.write(binary_image) f.close() scheduler() time.sleep(1) return 'success' # return send_api(received, img_path) return result['message']