Esempio n. 1
0
 def upload_file(login, password):
     '''
     Uploads files 
     '''
     db_obj = DataBaseCl()
     if db_obj.checkauth(login, password):
         if request.method == 'POST':
             f = request.files['file_name']
             if f:
                 if f.filename.split('.')[1] in ALLOWED_EXTENSIONS:
                     filename = secure_filename(f.filename)
                     path_f = os.path.join(app.config['UPLOAD_FOLDER'],
                                           filename)
                     f.save(path_f)
                     req = FileHandler(path_f)
                     res = req.parse_file()
                     return jsonify({'result:': res})
             else:
                 return 'not upload'
         return '''
         <!doctype html>
         <form action="" method=post enctype=multipart/form-data>
               <p><input type=file name= file_name> 
              <input type=submit value=Upload>
         </form>    
             '''
     else:
         return ('you have no permissions')
Esempio n. 2
0
 def upload_file(login, password):
     '''
     Uploads files 
     '''
     db_obj=DataBaseCl()
     if db_obj.checkauth(login, password):
         if request.method == 'POST':
             f = request.files['file_name']
             if f: 
                 if f.filename.split('.')[1] in ALLOWED_EXTENSIONS:
                     filename = secure_filename(f.filename)
                     path_f=os.path.join(app.config['UPLOAD_FOLDER'], filename)
                     f.save(path_f)
                     req=FileHandler(path_f)
                     res=req.parse_file()
                     return jsonify( { 'result:' : res} )
             else:
                 return 'not upload' 
         return '''
         <!doctype html>
         <form action="" method=post enctype=multipart/form-data>
               <p><input type=file name= file_name> 
              <input type=submit value=Upload>
         </form>    
             '''
     else:
         return ('you have no permissions')
Esempio n. 3
0
 def delete_items(table_name, params, login, password):
     '''
     Deletes items ftom the <table_name> table according to the parameters
     '''
     db_obj = DataBaseCl()
     if db_obj.checkauth(login, password):
         result = db_obj.db_func_delete(table_name, params)
         return jsonify({'result:': result})
     else:
         return ('You have no permissions')
Esempio n. 4
0
 def get_items(table_name, params, login, password):
     '''
     Returns all items of <table_name> table, according to the parameters
     '''
     db_obj = DataBaseCl()
     if db_obj.checkauth(login, password):
         result = db_obj.select_with_params(table_name, params)
         return jsonify({'result:': result})
     else:
         return ('You have no permissions')
Esempio n. 5
0
 def get_product_type(table_name, login, password):
     '''
     Returns all items of <table_name> table
     '''
     db_obj = DataBaseCl()
     if db_obj.checkauth(login, password):
         result = db_obj.select_without_params(table_name)
         return jsonify({'result:': result})
     else:
         return ('You have no permissions')
Esempio n. 6
0
 def delete_items(table_name, params,login, password):
     '''
     Deletes items ftom the <table_name> table according to the parameters
     '''
     db_obj=DataBaseCl()
     if db_obj.checkauth(login, password):
         result=db_obj.db_func_delete(table_name, params)
         return jsonify({ 'result:' : result})
     else:
         return ('You have no permissions')
Esempio n. 7
0
 def get_items(table_name, params,login, password):
     '''
     Returns all items of <table_name> table, according to the parameters
     '''
     db_obj=DataBaseCl()
     if db_obj.checkauth(login, password):
         result=db_obj.select_with_params(table_name, params)
         return jsonify( { 'result:' : result} )
     else:
         return ('You have no permissions')
Esempio n. 8
0
 def get_product_type(table_name,login, password):
     '''
     Returns all items of <table_name> table
     '''
     db_obj=DataBaseCl()
     if db_obj.checkauth(login, password):
         result=db_obj.select_without_params(table_name)
         return jsonify( { 'result:' : result} )
     else:
         return ('You have no permissions')