예제 #1
0
def inserir_atividade():
    #recebendo arquivo
    arquivo = request.files('arquivo')
    arquivo.filename = str(uuid.uuid4()) + os.path.splitext(
        arquivo.filename)[1]
    print(arquivo.filename)
    return ""
예제 #2
0
파일: main.py 프로젝트: ojhadiwesh/yogapose
def predict_pose():
	classifier = load_model('my_model_multiclass10.h5') #load the model that was created using cnn_multiclass.py
	test_image = request.files('file')
	#test_image = image.load_img('C:/Users/dojha/yogapose/plank.jpg', target_size = (64, 64)) #folder predictions with images that I want to test
	test_image = image.img_to_array(test_image)
	test_image = np.expand_dims(test_image, axis = 0)

	result = classifier.predict(test_image) # returns array

	if result[0][0] == 1:
		prediction = 'bridge' #predictions in array are in alphabetical order
	elif result[0][1] == 1:
		prediction = 'childspose'
	elif result[0][2] == 1:
		prediction = 'downwarddog'
	elif result[0][3] == 1:
		prediction = 'mountain'
	elif result[0][4] == 1:
		prediction = 'plank'
	elif result[0][5] == 1:
		prediction = 'seatedforwardbend'
	elif result[0][6] == 1:
		prediction = 'tree'
	elif result[0][7] == 1:
		prediction = 'trianglepose'
	elif result[0][8] == 1:
		prediction = 'warrior1'
	elif result[0][9] == 1:
		prediction = 'warrior2'


	return prediction
예제 #3
0
def upload():
    if ('user' in session and session['user'] == params['admin_user']):
        if(request.method=="POST"):
            f = request.files('file1')
            file = secure_filename(f.filename)
            f.save(os.path.join(app.config['UPLOAD_FOLDER'], file))
            return "Uploaded Successfully!"
예제 #4
0
파일: oldapp.py 프로젝트: s3724287/CueIt
def process_cue(file, filename):
    df1 = pd.read_csv(request.files('file'))
    df1.replace(to_replace=[
        "copy.01.new.01", "bounced", ".wav", ".", "aiff", "Bounce", "new 01",
        "WAV", "wav", ".new", "AIF"
    ],
                value=" ")
예제 #5
0
 def post(self):
     # simulacion de espera en el back con 1.5 segundos
     time.sleep(1)
     content = request.get_json()
     nombre = content.get("nombre")
     edad = content.get("edad")
     enfermedades = content.get("enfermedades")
     raza = content.get("raza")
     tamaño = content.get("tamaño")
     contacto = content.get("contacto")
     informacion = content.get("informacion")
     foto = request.files("foto")
     # comandos sql para agregar infomacion a la tabla users
     cur = mysql.connection.cursor()
     cur.execute(
         "INSERT INTO anuncio (nombre, edad, enfermedades, raza, tamaño, contacto, informacion, foto) VALUES (%s,%s,%s,%s,%s,%s,%s.%s)",
         (nombre, edad, enfermedades, raza, tamaño, contacto, informacion,
          filename))
     mysql.connection.commit()
     cur.close()
     return jsonify({
         "registro ok": True,
         "nombre": nombre,
         "edad": edad,
         "enfermedades": enfermedades,
         "raza": raza,
         "tamaño": tamaño
     }), 200
예제 #6
0
파일: server.py 프로젝트: ketan-16/FaceRec
 def post(self, id):
     print(request.files)
     img = request.files()['img']
     myquery = {"id": id}
     newvalues = {"$set": {"img": img}}
     mongo.db.user.update_one(myquery, newvalues)
     return {"message": "Image added successfully!!"}, 201  ###
예제 #7
0
def predict_image():
    if request.method == 'POST':
        # Step 1: check if the post request has the file part
        if 'file' not in request.files:
            return jsonify('No file found'), 400

        file = request.files('file')

        # Step 2: Basic file extension validation
        if file and allowed_file(file.filename):

            # Step 3: Save the file
            # Note, in production, this would require careful
            # validation, management and clean up

            file.save(os.path.join(UPLOAD_FOLDER, filename))

            _logger.debug(f'Inputs: {filename}')

            # Step 4: perform predictions
            result = make_single_prediction(
                image_name=filename,
                image_directory=UPLOAD_FOLDER)

            _logger.debug(f'Outputs: {result}')

        readable_predictions = result.get('readable_predictions')
        version = result.get('version')

        # Step 5: Return the response as JSON
        return jsonify({'readable_predictions': readable_predictions[0],
                        'version': version})
예제 #8
0
def uploader():
    if "user" in session and session['user'] == parameters['admin_user']:
        if (request.method == 'POST'):
            f = request.files('myfile')
            f.save(
                os.path.join(parameters["upload_loaction"],
                             secure_filename(f.filename)))
            return "uploaded succesfully"
예제 #9
0
def upload():
	file = request.files('file')
	if file and allowed_file(file.filename):
		#make filename save 
		filename = secure_filename(file.filename)
		#ove file from temporal to upload folder
		file.save(os.path.join(UPLOAD_FOLDER,filename))

		return jsonify({"success":"yes"})
예제 #10
0
def index():
    if request.method == "POST":
        f = open('./file.wav', 'wb')
        f.write(request.files("audio_data"))
        f.close()
        if os.path.isfile('./file.wav'):
            print("./file.wav exists")

        return render_template('index.html', request="POST")
    else:
        return render_template("index.html")
예제 #11
0
def uploader():
    session = {}
    if 'user' in session and session['user'] == params['admin_user']:
        f = request.files('file1')
        if f.filename == '':
            return "No selected file"

        if request.method == 'POST':
            f.save(
                os.path.join(app.config('UPLOAD_FOLDER'),
                             secure_filename(f.filename)))
    return "Successfully uploaded  the file"
예제 #12
0
def zone_entry():

    content = request.files('image')
    # zone_id = content['zone_id']
    # person_id = content['person_id']
    # image=content['image_str']
    # print(zone_id,person_id)
    print(content)

    #testing only

    # person_association.start_zone_camera_analysis(person_id,zone_id)

    return jsonify("person tracking and cart analysis started")
예제 #13
0
def post():
    # form表单数据
    name = request.form.get("name")
    age = request.form.get("age")

    # args查询字符串数据
    city = request.args.get("city")

    # data请求体, headers请求头
    data = request.data
    headers = request.headers

    # files获取上传的文件
    file_obj = request.files('pic')
    file_obj.save('test2.png')
    return name, age, city, data, headers
예제 #14
0
파일: server.py 프로젝트: ketan-16/FaceRec
 def post(self):
     print(request.get_json())
     id = request.get_json()['id']
     name = request.get_json()['name']
     branch = request.get_json()['branch']
     phone = request.get_json()['phone']
     mail = request.get_json()['email']
     img = request.files()['img']
     mongo.db.user.insert_one({
         "id": id,
         "name": name,
         "branch": branch,
         "phone": phone,
         "mail": mail,
         "isdeleted": False,
         "img": None
     })
     return {"message": "New User added successfully!!"}, 201
예제 #15
0
def addProduct():
    if not session.get('adminEmail'):
        return redirect('/admin/login')
    else:
        if request.method == 'GET':
            return render_template('admin/add-product.html')
        if request.method == 'POST':
            smallImagesFolder = os.pardir.join(
                getProjectRoot(),
                'modules/static/client/img/products/imgs_small')
            largeImagesFolder = os.path.join(
                getProjectRoot(),
                'modules/static/client/img/products/imgs_large')
            print(uploadFolder)

            if not os.path.isdir(uploadFolder):
                print("Not Dir")

            productName = request.form['productName']
            productDescription = request.form['productDescription']
            productSmallImages = request.files('productSmallImages')
            productLargeImages = request.files.getlist('productLargeImages')
            # Save in the database
            cursor = mysql.connection.cursor()
            cursor.execute(
                'INSERT INTO products (product_name, category_img_route) VALUES (%s, %s)',
                (categoryName, categoryImgRoute))
            mysql.connection.commit()
            # Save images in the server
            for productLargeImage in productLargeImages:
                filename, file_extension = os.path.splitext(
                    productImage.filename)
                destination = "/".join(
                    [largeImagesFolder,
                     productName.lower() + file_extension])
                productImgRoute = 'img/products/imgs_large' + productName.lower(
                ) + file_extension
                productImage.save(destination)

            return redirect('/admin/products?add=success')
예제 #16
0
def video_push_cache():
    '''推流'''
    file = request.files('uploaded_file')
    timeout = 10
    content = StringIO(file.read())

    #先把图像数据放入到setex中
        #先以时间戳生成key
    curimage_key = str(datetime.now)
    cache_db.setex(curimage_key,content,timeout)

    #生成序列组
    image_indexs = range(0,10)
    image_keys = cache_db.hmget('images',image_indexs)
    image_keys = image_keys[1:]
    image_keys.append(curimage_key)

    #更新
    vals = {}
    for i in image_indexs:
        vals.update({i:image_keys[i]})
    cache_db.hmset('images',vals)
예제 #17
0
def upload(subdir=''):
    file = request.files("file")
    if file:
        file.save(os.path.join(subdir, file.filename))
    return redirect(url_for("docs", subdir=subdir))
예제 #18
0
def upload():
    file = request.files(['file'])
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        return redirect(url_for('uploaded_file', filename = filename))
예제 #19
0
def add_task(title, id):
    if 'username' not in session:
        return redirect('/login')
    form = AddTaskForm()
    users = []
    title = int(title)
    users_ides = []
    text, links, hints, title1, content, choices, correct_choice = "", "", "", "", "", "", ""
    if request.method == 'GET':
        if title != -1 or title == -2:
            if title != -1 and title != -2:
                text, picture, links, hints, title1, content, choices, correct_choice = tasks_model.get(
                    session['task_id'][title])[1:]
                users_ides = [
                    i[-1]
                    for i in task_user.get_by_task(session['task_id'][title])
                ]
            elif title == -2:
                text, picture, links, hints, title1, content, choices, correct_choice = tasks_model.get(
                    id)[1:]
                users_ides = [i[-1] for i in task_user.get_by_task(id)]
            for i in users_ides:
                users.append(users_base.get(i)[1])
            form.text.data = text
            # form.picture.data = picture
            form.links.data = links
            form.hints.data = hints
            form.title.data = title1
            form.sentence.data = content
            form.choice.data = choices
            form.correct.data = correct_choice
    elif request.method == 'POST':
        text = form.text.data
        picture = None
        '''
        if allowed_file(f.filename):
            filename = secure_filename(f.filename)
            save_path = "{}/{}".format(app.config["UPLOAD_FOLDER"], filename)
            f.save(save_path)

        with open('static/' + f, 'w') as rf:
            rf.write(f.read().decode('utf-8'))
        '''
        links = form.links.data
        title1 = form.title.data
        sentence = form.sentence.data
        choice = form.choice.data.strip()
        correct = form.correct.data.strip()
        hints = form.hints.data.strip()
        '''
        if (len(sentence.split('\n')) != len(choice.split('\n')) or len(correct.split('\n')) != len(
                choice.split('\n'))) and choice != '':
            return render_template('add_task.html', form=form, username=session['username'], users=all_users,
                                   text='invalid task. Number of strings in labels "sentences",'
                                        ' "answer choice", "correct answer" must be the same')
                                        '''
        if not title and title1 in [i[1] for i in tasks_model.get_all()]:
            return render_template(
                'add_task.html',
                form=form,
                username=session['username'],
                users=all_users,
                text='задание с таким названием уже существует.')
        else:
            if title != -2 and title != -1:
                not_title_index, title_index = session['task_id'][
                    title], session['task_id'][title]
            elif title == -1:
                not_title_index, title_index = -1, -1
            else:
                not_title_index, title_index = id, id
            inserted = False
            if not title == -1 and id == -1:
                tasks_model.insert(text, picture, links, hints, title1,
                                   sentence, choice, correct)
                inserted = True
                not_title_index = tasks_model.index()
            ides = [j[0] for j in all_users]
            checked = []
            flag = False
            f = ''
            try:
                f = request.files('file')
            except Exception as e:
                pass
            else:
                with open('static/' + f, 'w') as rf:
                    rf.write(f.read().decode('utf-8'))
            for i in ides:
                if request.form.get(str(i)):
                    checked.append(i)
            else:
                if session[
                        'list_id'] not in checked and not inserted and title != -2:
                    tasks_model.insert(text, picture, links, hints, title1,
                                       sentence, choice, correct)
                    inserted = True
                    title_index = tasks_model.index()
                    flag = True
                elif title != -2:
                    tasks_model.update(text, picture, links, hints, title1,
                                       sentence, choice, correct,
                                       session['task_id'][title])
                elif title == -2:
                    tasks_model.update(text, picture, links, hints, title1,
                                       sentence, choice, correct, id)
            for i in checked:
                if title == -1 and id == -1:
                    task_user.insert(not_title_index, i)
                elif i not in [
                        j[1] for j in task_user.get_by_task(not_title_index)
                ]:
                    task_user.insert(title_index, i)
                    '''
                    if flag and title_index not in [i[1] for i in task_user.get_all(i)]:
                        task_user.insert(title_index, i)
                    elif not flag and not_title_index not in [i[1] for i in task_user.get_all(i)]:
                        task_user.insert(not_title_index, i)s
                        '''
            return redirect("/homepage")
    return render_template('add_task.html',
                           form=form,
                           checked=users,
                           username=session['username'],
                           users=all_users)
예제 #20
0
def uploader():  # for uploading files
    if 'user' in session and session['user'] == params['user1']:  # check if user already logged in
        if request.method == "POST":
            f = request.files('file1')
            f.save(os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(f.filename)))
            return "!! UPLOAD SUCCESSFUL !!"