def comment(id): if request.method == 'GET': return render_template('article.html') else: if not check_session(20): return "False, you have commented it in a short period." comment = request.form['comment'] email = request.form['email'] vcode = request.form['vcode'] if Serverdatabase.check_words(comment) and Serverdatabase.check_words( email) and Serverdatabase.check_words(vcode): if session['captcha'] == vcode: time = datetime.now() time = str(time) time = time[0:16] Serverdatabase.insert_comment(id, comment, email, time) info = Serverdatabase.article(id) info1 = Serverdatabase.article1(id) info2 = Serverdatabase.get_article_catalogue_info(id) info3 = Serverdatabase.get_count(id) tool = Tool() return render_template('article.html', info=info, info1=info1, info2=info2, id=id, info3=info3, tool=tool) else: return "Failed. Please enter the correct verification code " else: return "False, Please re-input, you maybe input " \ "inappropriate words include f**k, bitch, md, nmsl, idiot, shit, " \ "freak, foolish, liar, stupid, silly, jerk, prat, insane, rubbish, nonsense."
def api_upload(id): if request.method == 'GET': return render_template('Home1.html') app.logger.debug('get') else: title = request.form['title'] desc = request.form['content'] email = request.form['email'] abstract = request.form['abstract'] vcode = request.form['vcode'] id1 = str(uuid.uuid4()) print(id) if desc == '': return "false, please input the highlight." else: if Serverdatabase.check_words( title) and Serverdatabase.check_words( abstract) and Serverdatabase.check_words( desc) and Serverdatabase.check_words( vcode) and Serverdatabase.check_words(email): if session['captcha'] == vcode: file_dir = os.path.join( basedir, app.config['UPLOAD_FOLDER']) # 拼接成合法文件夹地址 if not os.path.exists(file_dir): os.makedirs(file_dir) # 文件夹不存在就创建 f = request.files[ 'myfile'] # 从表单的file字段获取文件,myfile为该表单的name值 if f and allowed_file(f.filename): # 判断是否是允许上传的文件类型 fname = f.filename ext = fname.rsplit('.', 1)[1] # 获取文件后缀 path = str(os.path.join(file_dir, fname)) time = datetime.now() time = str(time) time = time[0:16] print(os.path.join(file_dir, fname)) if ext == 'pdf': f.save(os.path.join(file_dir, fname)) if not check_session(100): return "False, you have upload it in a short period." Serverdatabase.upload(id1, fname, title, abstract, desc, email, path, time, id) return redirect(url_for('forum', id=id)) else: return "False. Please upload PDF file." else: return "Failed. Please enter the correct verification code " else: return "False, Please re-input, you maybe input " \ "inappropriate words include f**k, bitch, md, nmsl, idiot, shit, " \ "freak, foolish, liar, stupid, silly, jerk, prat, insane, rubbish, nonsense."
def add(): if request.method == 'GET': return render_template('fail.html') else: catalogue = request.form['catalogue'] desc = request.form['desc'] if catalogue == '' or desc == '': return "False, the input cannot be empty." else: if Serverdatabase.check_words( catalogue) and Serverdatabase.check_words(desc): if Serverdatabase.setCata(catalogue, desc): return redirect(url_for('catalogue')) else: return "False, There are the same subjects, please re-input." else: return "False, Please re-input, you maybe input " \ "inappropriate words include f**k, bitch, md, nmsl, idiot, shit, " \ "freak, foolish, liar, stupid, silly, jerk, prat, insane, rubbish, nonsense."
def search(id): if request.method == 'Get': return render_template('publish1.html', id=id) else: search_content = request.form['search_content'] if search_content == '': return "False, please input the information what you want to search." else: if Serverdatabase.check_words(search_content): info = Serverdatabase.search_articles(id, search_content) tool = Tool() return render_template('publish1.html', id=id, info=info, tool=tool) else: return "False, Please re-input, you maybe input " \ "inappropriate words include f**k, bitch, md, nmsl, idiot, shit, " \ "freak, foolish, liar, stupid, silly, jerk, prat, insane, rubbish, nonsense."