def insert(): message = request.form['message'] text = request.form['text'] message = message.replace("'", "''") db_class = db.Database() sql = """SELECT sentence FROM TS.sentence WHERE sentence = '%s'""" % ( message) data = db_class.executeOne(sql) if not data: sql = """INSERT INTO TS.sentence(sentence) \ VALUES('%s')""" % (message) db_class.execute(sql) sql = """UPDATE TS.sentence \ SET searchCnt = searchCnt + 1 \ WHERE sentence='%s'""" % (message) db_class.execute(sql) db_class.commit() if 'logged_in' in session and session['logged_in']: # login한 사용자는 저장. mM = user.memberManage() mM.insertSen(message, session['userid']) tr = paraphrase.paraphrase() translated = tr.papago(text, source="en") response_text = {"translated": translated} return jsonify(response_text)
def deletePara(): deletePara = request.form['deletePara'] userid = session['userid'] deletePara = deletePara.replace("'", "''") mM = user.memberManage() mM.deletePara(userid, deletePara.split(",")[:-1]) return ""
def deleteSen(): deleteSen = request.form['deleteSen'] userid = session['userid'] mM = user.memberManage() deleteSen = deleteSen.replace("'", "''") mM.deleteSen(userid, deleteSen.split(",")[:-1]) return ""
def save(): text = request.form['text'] title = request.form['title'] if 'logged_in' in session and session['logged_in']: mM = user.memberManage() mM.insertPara(session['userid'], text, title) return jsonify({"message": "저장되었습니다."}) else: return jsonify({"message": "로그인한 사용자만 이용 가능합니다."})
def load(): time = request.form['time'] userid = session['userid'] uM = user.memberManage() paragraph = uM.lookPara(userid, time) message = paragraph[0]['paragraph'] tr = paraphrase.paraphrase() translated = tr.papago(message, source="en") response_text = {"message": message, "translated": translated} return jsonify(response_text)
def login(): userid = request.form['userid'] pswd = request.form['pswd'] mM = user.memberManage() connect = mM.login(userid, pswd) if connect == 0: session['logged_in'] = True session['userid'] = userid session['pswd'] = pswd response_text = {"connect": connect, "id": userid} return jsonify(response_text)
def sen(): mM = user.memberManage() rows = mM.findSen(session['userid']) return render_template('sen.html', rows=rows)
def para(): mM = user.memberManage() rows = mM.findPara(session['userid']) return render_template('para.html', rows=rows)