def upload(): f = request.files["content"] f.save(os.path.join(app.config["FILE_ROOT"], secure_filename(f.filename))) regenerate_index(app.config["FILE_ROOT"], "index.html") response = make_response() response.headers["X-Swalow-Status"] = "SUCCESS" return response
def from_requirements(): if request.method == "POST": f = request.files['req_file'] filename = os.path.join(tempfile.gettempdir(),'temp-req.txt') f.save(filename) try: names = parse_reqs(filename, app.config['FILE_ROOT']) except: flash('There were some errors getting files from the uploaded requirements') else: flash('packages were installed from the requirements file. %s' % names) finally: regenerate_index(app.config['FILE_ROOT'],'index.html') return redirect('/requirements') return render_template('requirements_upload.html')
def from_requirements(): if request.method == "POST": f = request.files["req_file"] filename = os.path.join(tempfile.gettempdir(), "temp-req.txt") f.save(filename) try: names = parse_reqs(filename, app.config["FILE_ROOT"]) except: flash("There were some errors getting files from the uploaded requirements") else: flash("packages were installed from the requirements file. %s" % names) finally: regenerate_index(app.config["FILE_ROOT"], "index.html") return redirect("/requirements") return render_template("requirements_upload.html")
from utils import regenerate_index from cheese_emporium import FILE_ROOT if __name__ == "__main__": regenerate_index(FILE_ROOT, 'index.html')
def regenerate(): if request.method == 'POST': regenerate_index(app.config['FILE_ROOT'],'index.html') flash('Index has been regenerated.') return redirect('/') return render_template('regenerate.html')
req = Request(url) f = urlopen(req) print "downloading " + url # Open our local file for writing local_file = open(os.path.join(app.config['FILE_ROOT'],filename), "w") #Write to our local file local_file.write(f.read()) local_file.close() print 'finished downloading' #handle errors except HTTPError, e: print "HTTP Error:", e.code , url except URLError, e: print "URL Error:", e.reason , url regenerate_index(app.config['FILE_ROOT'],'index.html') flash('%s-%s was installed into the index successfully.' % (name, version)) return redirect('/') @app.route('/regenerate-index',methods=['POST', 'GET']) def regenerate(): if request.method == 'POST': regenerate_index(app.config['FILE_ROOT'],'index.html') flash('Index has been regenerated.') return redirect('/') return render_template('regenerate.html') @app.route('/requirements',methods=['POST','GET']) def from_requirements():
def regenerate(): if request.method == "POST": regenerate_index(app.config["FILE_ROOT"], "index.html") return redirect("/index") return render_template("regenerate.html")
req = Request(url) f = urlopen(req) print "downloading " + url # Open our local file for writing local_file = open(os.path.join(app.config["FILE_ROOT"], filename), "w") # Write to our local file local_file.write(f.read()) local_file.close() print "finished downloading" # handle errors except HTTPError, e: print "HTTP Error:", e.code, url except URLError, e: print "URL Error:", e.reason, url regenerate_index(app.config["FILE_ROOT"], "index.html") flash("%s-%s was installed into the index successfully." % (name, version)) return redirect("/") @app.route("/regenerate-index", methods=["POST", "GET"]) def regenerate(): if request.method == "POST": regenerate_index(app.config["FILE_ROOT"], "index.html") return redirect("/index") return render_template("regenerate.html") @app.route("/requirements", methods=["POST", "GET"]) def from_requirements(): if request.method == "POST":