Example #1
0
def kria_upload_foun():
    category = request.forms.get('category')
    upload = request.files.get('upload')
    name, ext = os.path.splitext(upload.filename)
    if ext not in ('.png', '.jpg', '.jpeg', '.JPG', '.gif'):

        return "File extension not allowed."

    save_path = "static/upload/"  ####{category}".format(category=category)
    if not os.path.exists(save_path):
        os.makedirs(save_path)

    file_path = "{category}/{upload}".format(category=save_path,
                                             upload=upload.filename)

    upload.save(file_path)

    connection = sqlite3.connect("test.db")
    connection.execute(
        "INSERT INTO upload( category, upload) VALUES ( '{category}', '{upload}')"
        .format(category=category, upload=upload.filename))

    connection.commit()
    id = connection.execute('SELECT last_insert_rowid()').next()[0]
    connection.close()
    entries = [(id, category, upload.filename)]
    return template("template/upload.html", entries=entries)
Example #2
0
def startTimelapse():
    path = USBPATH + "timelapses/" + time.strftime('%Y-%m-%d')
    if not os.path.exists(path):
        os.makedirs(path)
    os.system("raspistill -w 1920 -h 1080 -o " + path +
              r"/%05d.jpg -tl 5000 -t 84700000 -l "
              "/home/pi/pitimelapse/latest.jpg &")
Example #3
0
def music_troka(id=id):
    category = request.forms.get('category')
    upload = request.files.get('upload')
    name, ext = os.path.splitext(upload.filename)
    if ext not in ('.mp3', '.MP3'):
        return "File extension not allowed."

    save_path = "static/audios/"  ##====={category}".format(category=category)
    if not os.path.exists(save_path):
        os.makedirs(save_path)

    file_path = "{category}/{upload}".format(category=save_path,
                                             upload=upload.filename)
    upload.save(file_path)
    connection = sqlite3.connect('test.db')
    query = "UPDATE music set category='{category}', upload='{upload}' WHERE id={id}".format(
        category=category, upload=upload.filename, id=id)
    entries = connection.execute(query)
    connection.commit()
    entries = [(id, category, upload.filename)]
    return template('template/music.html', entries=entries)
def newUser():
    data = request.json
    try:
        username = data["Name"]
        password = data["Password"]
        confirmPass = data["ConfirmPassword"]
    except:
        return "Error: Missing args."

    if confirmPass == password:
        if not username in Users:
            Users[username] = encrypt(password)
            Open_File("Users.txt", True, str(Users))
            os.makedirs("Assets/Users/" + username)
            Open_File("Assets/Users/" + username + "/Projects.txt", True,
                      str([]))
            Open_File("Assets/Users/" + username + "/Logo.txt", True,
                      "/home/ItchIcon.png")
            return "Ok"
        else:
            return "Error: User already exists."
    else:
        return "Error: Password and confirm password do not match."