Exemple #1
0
def upload_file_combined():
	form = UploadForm()
	if request.method == 'POST':
		file = request.files['file']
		if file and allowed_file(file.filename):
			filename = secure_filename(file.filename)
			hash = hashlib.md5()
			hash.update(filename);
			global counter
			new_filename = str(hash.hexdigest()[14:]) + '_' + str(random.random()*100) + str(counter)
			hash.update(new_filename)
			counter = counter + 1
			filename = hash.hexdigest()[20:] + '_' + filename
			hashstring = str(hash.hexdigest()[20:])
			path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
			print path
			file.save(path)
			url = url_for('uploaded_file', filename=filename)
			post = Post()
			post.title = form.title.data
			post.slug = hashstring
			post.geoLong = form.geoLong.data
			post.geoLat = form.geoLat.data
			post.image_url = url
			post.save()
			return redirect("/all-list")
Exemple #2
0
def create():
	post = Post()
	post.title = request.args.get('title', '')
	post.slug = request.args.get('slug', '')
	post.geoLong = request.args.get('geoLong', '')
	post.geoLat = request.args.get('geoLat', '')
	post.image_url = request.args.get('image_url', '')
	post.save()
	data = {
			"response" : "Success",
			}
	return jsonify(data)