示例#1
0
def postRelease():
    #add keys or files or .. to the db through client
    db = Db('database.db')
    if(request.is_json):
        ##get parameters
        content = request.get_json()
        data = json.loads(content)
        res = db.insert_Release(data)
        return jsonify(result=res)
    else:
        return jsonify(result=False)
示例#2
0
def queryPK():
    #add keys or files or .. to the db through client
    db = Db('database.db')
    if(request.is_json):
        ##get parameters
        content = request.get_json()
        data = json.loads(content)
        res = db.findPk(data['name'])

        return jsonify(res)
    else:
        return jsonify(result=False)
示例#3
0
def uploadData():
    #add keys or files or .. to the db through client
    db = Db('database.db')

    chunk_size = 4096
    while True:
        chunk = request.stream.read(chunk_size)
        if len(chunk) == 0:
            return
        
        res = db.insert_data(chunk) #should return an id 
        return jsonify(result=res)
    else:
        return jsonify(result=False)
示例#4
0
def listkeys():
    if 'username' in session:
        db = Db('database.db')
        body = Markup("<a href='/'>home</a></br>")
        body += Markup("</br>")
        pks = db.get_pubkeys();
        body+=Markup("<table><th>name</th><th>pubkey</th><th>signed</th><tbody>")
        for i in pks:
            body+=Markup("<tr>")
            for j in i:
                body += Markup("<td>")+str(j)+Markup("</td>")
            body+=Markup("</tr>")
        body+=Markup("</tbody></table>")
        body += Markup("</br>")
        return render_template('index.html', content=body)
    else:
        return redirect('/')
示例#5
0
def login():
    db = Db('database.db')
    
    error = None
    if request.method == 'POST':
        name = request.form['username']
        passw = request.form['password']
        if(db.login(name,passw)):
            #set the user as active
            session['username'] = name
            #global u
            #u = User(request.form['username'],True)
            return redirect('/protected')
        else:
            error = "That didn't work"

    return render_template('login.html', error=error)
示例#6
0
def register():
    db = Db('database.db')
    #db.create_db()

    error = None
    if request.method == 'POST':
        name = request.form['username']
        passw = request.form['password']
        email = request.form['email']
        if(db.insert(name,passw,email)):
            #set the user as active            
            #u = User(request.form['username'],True)
            session['username'] = name
            return redirect('/protected')
        else:
            error = "Name exists, please chose a different one"

    return render_template('register.html', error=error)