Exemple #1
0
def upload_file():
    uploaded_file = request.files['inputFile']
    if uploaded_file and allowed_file(uploaded_file.filename):
        filename = secure_filename(uploaded_file.filename)
        temp_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
        uploaded_file.save(temp_path)
        #should check if this is proper xml (check against schema maybe and check if its malicious in any way?)'
        #get a recipe model object with the unpacked list returned from process_recipe and save it to the db
        try:
            recipe = Recipe(temp_path)
        except:
            os.remove(temp_path)
            print 'error parsing xml file'
        save_model_to_db(recipe)
        ##remove the xml file and redirect to main view.
        os.remove(temp_path)
        return redirect(url_for('main'))
Exemple #2
0
def register():
    user = User(request.form['username'], 
                request.form['password'])
    save_model_to_db(user)
    return redirect(url_for('login'))