def modify(cityid): uid = if_signin(session) db = open_db() description = description_get(db,cityid) root = if_root(db,uid) close_db(db) return render_template('modification.html',description = description,username = session['username'],cityid = cityid,root = root[0])
def area(cityid): uid = if_signin(session) db = open_db() content = execute_sql(db, "select id,name,description,picture from city where id = '"+cityid+"'", 'fetchall') root = if_root(db,uid) cities = id_name_get(db) close_db(db) return render_template('area.html',cities = cities,username = session['username'],content = content,cityid = cityid,root = root[0],uid = uid)
def upload_post(cityid): file = request.files['file'] if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) db = open_db() execute_sql(db, "UPDATE city SET picture = '"+filename+"'WHERE id = '"+cityid+"'",'update') close_db(db) return render_template('upload-process.html',cityid = cityid,filename = filename)
def register(): username = request.form['regUsername'] password = request.form['regPassword'] print(password) db = open_db() if len(username) <= 20 and 7 <= len(password) <= 20: execute_sql(db, "insert into user (username, password,root) values('"+ username + "', '" + password +"','0')", 'insert') uid = execute_sql(db, "select id from user where username = '******'", 'fetchone') close_db(db) session['username'] = username session['uid'] = uid[0] return "success" else: close_db(db) return "outOfRange"
def Signin(): username = request.form['signUsername'] password = request.form['signPassword'] db = open_db() if len(username) <= 20 and 7 <=len(password) <= 20: data = execute_sql(db, "select id, username, password from user where username = '******'", 'fetchall') close_db(db) if data and password == data[0][2]: session['uid'] = data[0][0] session['username'] = data[0][1] return "success" return "fault" else: close_db(db) return "outOfRange"
def modification(cityid): modification = request.form['description'] db = open_db() execute_sql(db, "UPDATE city SET description = '"+modification+"'WHERE id = '"+cityid+"'", 'update') close_db(db) return "success"
def home(): uid = if_signin(session) db = open_db() cities = id_name_get(db) close_db(db) return render_template('newchina.html', username = session['username'],uid = uid,cities = cities)