コード例 #1
0
ファイル: app.py プロジェクト: david500834/lamome
def index_banner():
	folder = "static/upload/index_banner"
	if os.path.exists(folder)==False:
			os.makedirs(folder)


	if request.method == "GET":
		banner_json = read_mongo().get_index_banner()
		
	elif request.method == "POST":
		file_th = request.form["banner_th"]
		print file_th
		file = request.files["file"]
		
		if file and allowed_file(file.filename):
			# filename = secure_filename(file.filename)
			filename= "banner"+file_th+".jpg"
			file.save(os.path.join(folder, filename))
			banner_json = read_mongo().get_index_banner()
			banner_json[file_th] = filename
			write_mongo().index_banner(banner_json)

		banner_json = read_mongo().get_index_banner()

		
	



	


	return render_template("/dashboard/index_banner.html",banner_json=banner_json)
コード例 #2
0
ファイル: app.py プロジェクト: david500834/lamome
def product_post():
	if request.method == "GET":
		return render_template("/dashboard/product_post.html")
	elif request.method == "POST":

		product_header = request.form["product_header"]
		product_type = request.form["product_type"]
		product_class = request.form["product_class"]

		folder = "static/upload/product/"+product_class
		print folder
		if os.path.exists(folder)==False:
			os.makedirs(folder)

		file = request.files["file"]

		if file and allowed_file(file.filename):
			filename = secure_filename(file.filename)
			file.save(os.path.join(folder, filename))


		
		product_intro = request.form["product_intro"]
		product_json = {"name":product_header,
			   			"intro":product_intro,
			   			"product":product_class,
			   			"img_name":filename}
		write_mongo().product_upload(product_json)
		


		#验证通过,此处可以上传所有参数

		return render_template("/dashboard/product_post.html")
コード例 #3
0
ファイル: app.py プロジェクト: david500834/lamome
def product_manage():
	product_json = read_mongo().get_product()
	len_json = len(product_json)-1

	if request.method == "POST":
		product = request.form["product"]
		product_temp = request.form["product_temp"]
		if product!=product_temp:
			product=product_temp
		name = request.form["name"]
		print name,"===="*10,type(name)
		intro = request.form["intro"]
		id_ = request.form["id"]
		

		pu = {"name":name,"intro":intro,"product":product}
		
		print "!!!",pu,"!!!"
		write_mongo().update_product(pu,id_)


		product_json = read_mongo().get_product()
		en_json = len(product)-1

	return render_template("/dashboard/product_manage.html",json=product_json,len_p=len_json)
コード例 #4
0
ファイル: app.py プロジェクト: david500834/lamome
def index_menu():
	
	if request.method == "GET":
		index_menu_json = read_mongo().get_index_menu()
		return render_template("/dashboard/index_menu.html",json=index_menu_json)
	elif request.method == "POST":
		key_1 = request.form["tag_1"]
		key_2 = request.form["tag_2"]
		key_3 = request.form["tag_3"]
		key_4 = request.form["tag_4"]
		key_5 = request.form["tag_5"]
		key_6 = request.form["tag_6"]
		value_1 = request.form["value_1"]
		value_2 = request.form["value_2"]
		value_3 = request.form["value_3"]
		value_4 = request.form["value_4"]
		value_5 = request.form["value_5"]
		value_6 = request.form["value_6"]
		mongo_json = {key_1:value_1,key_2:value_2,key_3:value_3,key_4:value_4,key_5:value_5,key_6:value_6}
		write_mongo().index_menu(mongo_json)
		index_menu_json = read_mongo().get_index_menu()
		return render_template("/dashboard/index_menu.html",json=index_menu_json)
コード例 #5
0
ファイル: app.py プロジェクト: david500834/lamome
def product_show():
	folder = "static/upload/product_show"
	if os.path.exists(folder)==False:
			os.makedirs(folder)

	if request.method == "GET":
		product_show_json = read_mongo().get_product_show()
	elif request.method == "POST":
		product_name = request.form["product_name"]
		name = request.form["name"]
		index_name = request.form["index"]
		print product_name,name
		
		file = request.files["file"]

		if file and allowed_file(file.filename):
			# filename = secure_filename(file.filename)
			filename = "product_"+index_name+".jpg"
			file.save(os.path.join(folder, filename))

			product_show_json = read_mongo().get_product_show()
			product_show_json.pop(name)

			product_show_json[product_name] = filename
			print product_show_json
			write_mongo().product_show(product_show_json)


		product_show_json = read_mongo().get_product_show()






	return render_template("/dashboard/product_show.html",json=product_show_json)
コード例 #6
0
ファイル: app.py プロジェクト: david500834/lamome
def delet_product():
	id_ = request.args["id"]
	write_mongo().delet_product(id_)
	product_json = read_mongo().get_product()
	len_json = len(product_json)-1
	return render_template("/dashboard/product_manage.html",json=product_json,len_p=len_json)