diff --git a/.gitignore b/.gitignore index 2fa00ab..87a3348 100644 --- a/.gitignore +++ b/.gitignore @@ -165,4 +165,6 @@ cython_debug/ .AppleDouble .LSOverride -*.ini \ No newline at end of file +### 제외 파일 ### +*.ini +*.ipynb \ No newline at end of file diff --git a/app.py b/app.py index 504595d..231f1d8 100644 --- a/app.py +++ b/app.py @@ -1,51 +1,71 @@ -# -*- coding:utf-8 -*- - -import configparser -from flask import Flask - +from flask import Flask, request, render_template, redirect, url_for app = Flask(__name__) @app.route('/') def hello(): - return result + return 'Hello, World!' + +@app.route('/hello') +def hellohtml(): + return render_template("hello.html") + +@app.route('/hellos/') +def hellos(name): + return "hellos {}".format(name) + +@app.route('/input/') +def input(num): + name = '' + if num == 1: + name = '도라에몽' + elif num == 2: + name = '진구' + elif num == 3: + name = '퉁퉁이' + return "hello {}".format(name) + +app.route('/test') +def test1(): + return 'test1' + +@app.route('/test/') +def test2(): + return 'test2' + +@app.route('/naver') +def naver(): + return render_template("naver.html") + +@app.route('/kakao') +def daum(): + return redirect("https://www.daum.net/") + +@app.route('/urltest') +def url_test(): + return redirect(url_for('daum')) + +@app.route('/dora') +def myimage(): + return render_template("myimage.html") + +@app.route('/form') +def formhtml(): + return render_template("form.html") + +@app.route('/method', methods=['GET', 'POST']) +def method(): + if request.method == 'GET': + # args_dict = request.args.to_dict() + # print(args_dict) + num = request.args["num"] + name = request.args.get("name") + return "GET으로 전달된 데이터({}, {})".format(num, name) + else: + num = request.form["num"] + name = request.form["name"] + return "POST로 전달된 데이터({}, {})".format(num, name) if __name__ == '__main__': - app.run() - -import pymysql - -config = configparser.ConfigParser() - -# DB 연결 설정 정보 세팅 ( db_config.ini에 정의 ) -config.read(os.getcwd() + os.sep + 'db_config.ini', encoding='utf-8') - -conn = pymysql.connect( - host = config.get('DB_CONFIG', 'HOST'), - port = int(config['DB_CONFIG']['PORT']), - user= config['DB_CONFIG']['USER'], - passwd= config.get('DB_CONFIG', 'PASSWD'), - db= config['DB_CONFIG']['DBNAME'], - charset="utf8") - -# Tuple -cur = conn.cursor() - -# DictCursor -cur = conn.cursor(pymysql.cursors.DictCursor) - -sql = f"""SELECT * FROM authority - """ - -# sql = f"""SELECT * FROM product -# """ -#cur.execute("set name utf8") - -cur.execute(sql) - -# 데이터 접근 -result = cur.fetchall() - -# 연결 종료 -conn.close() - -print(result) \ No newline at end of file + with app.test_request_context(): + print(url_for('daum')) + app.run() \ No newline at end of file diff --git a/app2.py b/app2.py new file mode 100644 index 0000000..94ad992 --- /dev/null +++ b/app2.py @@ -0,0 +1,51 @@ +# -*- coding:utf-8 -*- + +import configparser +import os +from flask import Flask +import pymysql + +config = configparser.ConfigParser() + +# DB 연결 설정 정보 세팅 ( db_config.ini에 정의 ) +config.read(os.getcwd() + os.sep + 'db_config.ini', encoding='utf-8') + +conn = pymysql.connect( + host = config.get('DB_CONFIG', 'HOST'), + port = int(config['DB_CONFIG']['PORT']), + user= config['DB_CONFIG']['USER'], + passwd= config.get('DB_CONFIG', 'PASSWD'), + db= config['DB_CONFIG']['DBNAME'], + charset="utf8") + +# Tuple +cur = conn.cursor() + +# DictCursor +cur = conn.cursor(pymysql.cursors.DictCursor) + +sql = f"""SELECT * FROM authority + """ + +# sql = f"""SELECT * FROM product +# """ +#cur.execute("set name utf8") + +cur.execute(sql) + +# 데이터 접근 +result = cur.fetchall() + +# 연결 종료 +conn.close() + +print(result) + +app = Flask(__name__) + +@app.route('/') +def hello(): + return result + +if __name__ == '__main__': + app.run() diff --git a/static/img/dora.png b/static/img/dora.png new file mode 100644 index 0000000..60ec49c Binary files /dev/null and b/static/img/dora.png differ diff --git a/templates/form.html b/templates/form.html new file mode 100644 index 0000000..b3947d9 --- /dev/null +++ b/templates/form.html @@ -0,0 +1,16 @@ + + + + +

WMS

+ +
+
+
+
+

+ +
+ + + \ No newline at end of file diff --git a/templates/hello.html b/templates/hello.html new file mode 100644 index 0000000..badd600 --- /dev/null +++ b/templates/hello.html @@ -0,0 +1 @@ +hello no1 \ No newline at end of file diff --git a/templates/myimage.html b/templates/myimage.html new file mode 100644 index 0000000..8dd1b2d --- /dev/null +++ b/templates/myimage.html @@ -0,0 +1,13 @@ + + + + +

도라에몽

+ + + + + + + + \ No newline at end of file diff --git a/templates/naver.html b/templates/naver.html new file mode 100644 index 0000000..d27997e --- /dev/null +++ b/templates/naver.html @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file