Example #1
0
def insertProject():
    json = request.form
    if (json == None):
        print("\nNB_ERROR: CAN NOT FIND FORM DATA\n")
        return
    about = json.get('about')
    subject = json.get('subject')
    body = json.get('body')
    url = json.get('url')
    #이미지 파일 저장 부분
    img = request.files.get('img')
    if img is not None:
        filename = subject + "_" + datetime.today().strftime(
            "%Y%m%d%H%M%S") + "." + secure_filename(
                img.filename).split(".")[-1]
        print("\nFILE NAME IS ::" + filename + "\n")
        if not allowed_file(filename):
            abort(400)
        img.save('.' + IMG_PATH + filename)
    else:
        filename = None
    if filename is not None and allowed_file(filename) is False:
        print("ERROR :: IMAGE INSERT FAILED!")
        abort(400)
    print(filename, "filename\n")
    #DB 삽입
    connect = dbinit.db_connect()
    cur = connect.cursor()
    query = "INSERT INTO project (about, subject, body, url, img) VALUES (%s, %s, %s, %s, %s)"
    cur.execute(query, (about, subject, body, url, filename))
    connect.commit()
    connect.close()
    #종료
    return jsonify(result="success")
Example #2
0
def introduceInfo():
    connect = dbinit.db_connect()
    cur = connect.cursor()
    query = "SELECT * FROM introduce"
    cur.execute(query)
    data = cur.fetchone()
    connect.close()
    return jsonify(data)
Example #3
0
def projectInfo():
    connect = dbinit.db_connect()
    cur = connect.cursor()
    query = "SELECT * FROM project"
    cur.execute(query)
    datas = cur.fetchall()
    connect.close()
    return jsonify(datas)
Example #4
0
def projectDelte():
    connect = dbinit.db_connect()
    cur = connect.cursor()
    json = request.form
    if (json == None):
        print("\nNB_ERROR: CAN NOT FIND FORM DATA\n")
        return
    postid = json['post_id']
    query = "DELETE FROM project WHERE post_id = %s"
    cur.execute(query, (postid))
    connect.commit()
    connect.close()
    return jsonify(result="success")
Example #5
0
def insertIntroduce():
    json = request.form
    if (json == None):
        print("\nNB_ERROR: CAN NOT FIND FORM DATA\n")
        return
    old = json.get('old')
    project = json.get('project')
    competition = json.get('competition')
    print(old, project, competition)
    connect = dbinit.db_connect()
    cur = connect.cursor()
    query = "UPDATE introduce SET old=%s, project=%s, competition=%s WHERE user_id=1"
    cur.execute(query, (old, project, competition))
    connect.commit()
    connect.close()
    return jsonify(result="success")
Example #6
0
def validateLogin():
    username = request.form['ID']
    password = request.form['PW']
    hash_id = md5.to_hash(username)
    hash_pw = md5.to_hash(password)
    connect = dbinit.db_connect()
    cur = connect.cursor()
    query = "SELECT id, pw FROM user"
    cur.execute(query)
    data = cur.fetchone()
    connect.close()
    if (hash_id == data[0] and hash_pw == data[1]):
        print("Admin Login Success")
        return render_template('setting.html')
    else:
        print("Wrong ID or PW")
        return render_template('admin.html')
Example #7
0
def insertExperience():
    json = request.form
    if (json == None):
        print("\nNB_ERROR: CAN NOT FIND FORM DATA\n")
        return
    subject = json['subject']
    project = json['project']
    location = json['location']
    startdate = json['startdate']
    enddate = json['enddate']
    #DB 삽입
    connect = dbinit.db_connect()
    cur = connect.cursor()
    query = "INSERT INTO experience (subject, project, location, startdate, enddate) VALUES (%s, %s, %s, %s, %s)"
    cur.execute(query, (subject, project, location, startdate, enddate))
    connect.commit()
    connect.close()
    #종료
    return jsonify(result="success")