import os import click from flask import Flask, render_template, request, redirect, send_file import shutil import glob app = Flask(__name__) @app.route('/', methods=['GET']) def home(): return render_template('index.html') import datetime # def crop_Alluq(): # import os # cmd = "python .\\sepration_crop.py" # os.system(cmd) # # import os # cmd = "python .\\front_face.py" # os.system(cmd) # # import os # cmd = "python .\\sepration_cluster.py" # os.system(cmd) # # import os # cmd = "python .\\unique_1.py" # os.system(cmd) # # import os # cmd = "python .\\unique_Allunq.py" # os.system(cmd) # # # import os # # cmd = "python .\\Allunq_copy_gallery.py" # # os.system(cmd) # # import os # cmd = "python .\\remove.py" # os.system(cmd) # # # def sync_Alluq_people(): # import os # cmd = "python .\\Allunq_People.py" # os.system(cmd) def crop_Alluq(eventid,original_working_directory): print("started with images") import os cmd = "python "+original_working_directory+"\\sepration_crop.py"+" "+str(eventid) os.system(cmd) import os cmd = "python "+original_working_directory+"\\front_face.py"+" "+str(eventid) os.system(cmd) import os cmd = "python "+original_working_directory+"\\sepration_cluster.py"+" "+str(eventid) os.system(cmd) import os cmd = "python "+original_working_directory+"\\unique_1.py"+" "+str(eventid) os.system(cmd) #eventid="789456123" import os cmd = "python "+original_working_directory+"\\is_existALLUNQ.py"+" "+str(eventid) os.system(cmd) import os cmd = "python "+original_working_directory+"\\Allunq_copy_gallery.py"+" "+str(eventid) os.system(cmd) import os cmd = "python "+original_working_directory+"\\Allunq_People.py"+" "+str(eventid) os.system(cmd) return "ended with images" # import os # cmd = "python .\\remove.py" # os.system(cmd) def sync_Alluq_people(eventid,original_working_directory): import os cmd = "python "+original_working_directory+"\\Allunq_People.py"+" "+str(eventid) os.system(cmd) return "ended with images" def create_dir(eventid,original_working_directory): # original_working_directory = os.getcwd() # new_networked_directory = r'\\192.168.88.99\\Bizgaze\\port6003\\wwwroot\\_files\\' # # change to the networked directory # os.chdir(new_networked_directory) print(original_working_directory) from pathlib import Path Path(original_working_directory+'\\front_face\\' + eventid).mkdir(exist_ok=True) Path(original_working_directory+'/sepration_cluster/'+eventid).mkdir(exist_ok=True) Path(original_working_directory+'/sepration_crop/' + eventid).mkdir(exist_ok=True) Path(original_working_directory+'/unique_1/' + eventid).mkdir(exist_ok=True) Path('ALL_UNQ/' + eventid).mkdir(exist_ok=True) Path(original_working_directory+'/output_unique_ALLUNQ/' + eventid).mkdir(exist_ok=True) Path(original_working_directory+'/people_Allunq_zero_maingallery/' + eventid).mkdir(exist_ok=True) Path(original_working_directory+'/Allunq_People/' + eventid).mkdir(exist_ok=True) Path(original_working_directory+'/Allunq_CopyGallery/' + eventid).mkdir(exist_ok=True) @app.route('/eventwise', methods=["GET", "POST"]) def eventwise(): import os original_working_directory = os.getcwd() new_networked_directory = r'\\192.168.88.99\\Bizgaze\\port6003\\wwwroot\\_files' # change to the networked directory os.chdir(new_networked_directory) eventid= request.args.get('Dataset') # Id.append(Events) create_dir(eventid,original_working_directory) import pathlib file = pathlib.Path(new_networked_directory+"/"+eventid+"/"+"Thumbs.db") if file.exists (): os.remove(new_networked_directory+"/"+eventid+"/"+'Thumbs.db') else: pass x = datetime.datetime.now() print('Execution Started at:', x) import os # path of the directory for dirpath, dirnames, files in os.walk('1/CopyGallery/' + eventid + '/'): if os.listdir(dirpath)==[]: #f = os.path.join(root, name) # Checking the length of list #if len((f)) == 0: print("No files found in the directory.") print("working on sync_Alluq_people.........") sync_Alluq_people(eventid,original_working_directory) else: print("Some files found in the directory.") print("working on crop_Alluq.........") crop_Alluq(eventid,original_working_directory) return "ended with images" # # # import os # cmd = "python .\\people_Allunq_zero_maingallery.py" # os.system(cmd) # import os # cmd = "python .\\remove.py" # os.system(cmd) # import requests # import json # with open('C:\\Users\\Bizgaze\\Desktop\\AI\\AI_Events\\csv\\EventXtream.json', 'r') as json_file: # json_load = json.load(json_file) # url = "http://localhost:3088/apis/v4/bizgaze/integrations/json/save" # payload1 = json.dumps(json_load).replace("]", "").replace("[", "") # print('--------------------------------------------------------------------------') # print(payload1) # headers = { # 'Authorization': 'Stat a528db7c512f494eab8bfef012c220e0', # 'Content-Type': 'application/json' # } # response = requests.request("POST", url, headers=headers, data=payload1) # print("##############################################################") # print(response.text) # y = datetime.datetime.now() # print('Completed at:', y) # z = y - x # print('Time Taken:', z) # return render_template('index.html') # # return 'ALL IMAGES MATCHED' @app.route('/json') def json(): p = './path.json' return send_file(p, as_attachment=True) if __name__ == "__main__": app.run(host="0.0.0.0",port=5001,debug=True)