mirror of
https://github.com/suhf/No1WMSPython.git
synced 2026-02-04 12:13:27 +09:00
html 화면 변경 및 db select 구현
This commit is contained in:
82
app.py
82
app.py
@@ -1,9 +1,61 @@
|
|||||||
from flask import Flask, request, render_template, redirect, url_for
|
from flask import Flask, request, render_template, redirect, url_for
|
||||||
|
|
||||||
|
# db연결 패키지 import
|
||||||
|
import configparser
|
||||||
|
import os
|
||||||
|
import pymysql
|
||||||
|
# ---
|
||||||
|
|
||||||
|
# DB 연결 설정 정보 세팅 ( db_config.ini에 정의 )
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
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 wms.plan_In2
|
||||||
|
# """
|
||||||
|
|
||||||
|
sql = f"""SELECT * FROM wms.plan_In2 where qr_hash=%s
|
||||||
|
"""
|
||||||
|
|
||||||
|
cur.execute(sql, 'testqr')
|
||||||
|
|
||||||
|
# 데이터 접근
|
||||||
|
# result = cur.fetchall()
|
||||||
|
rows = cur.fetchall()
|
||||||
|
# result = cur.fetchone()
|
||||||
|
|
||||||
|
# for record in result:
|
||||||
|
# print(record)
|
||||||
|
|
||||||
|
# 연결 종료
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
for row in rows:
|
||||||
|
# print(row)
|
||||||
|
print(row['quantity'], row['qr_hash'], row['date'])
|
||||||
|
|
||||||
|
# rows = [list(rows[x]) for x in range(len(rows))]
|
||||||
|
#------------------------------------------------
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello():
|
def hello():
|
||||||
return 'Hello, World!'
|
# return 'Hello, World!'
|
||||||
|
return rows
|
||||||
|
|
||||||
@app.route('/hello')
|
@app.route('/hello')
|
||||||
def hellohtml():
|
def hellohtml():
|
||||||
@@ -50,20 +102,34 @@ def myimage():
|
|||||||
|
|
||||||
@app.route('/form')
|
@app.route('/form')
|
||||||
def formhtml():
|
def formhtml():
|
||||||
return render_template("form.html")
|
# return render_template("form.html", date = row['date'], warehouse_id = row['warehouse_id'], name = row['name'], quantity = row['quantity'])
|
||||||
|
return render_template("form.html", date = row['date'], warehouse_id = row['warehouse_id'], quantity = row['quantity'])
|
||||||
|
|
||||||
@app.route('/method', methods=['GET', 'POST'])
|
@app.route('/method', methods=['GET', 'POST'])
|
||||||
def method():
|
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 request.method == 'GET':
|
if request.method == 'GET':
|
||||||
# args_dict = request.args.to_dict()
|
# args_dict = request.args.to_dict()
|
||||||
# print(args_dict)
|
# print(args_dict)
|
||||||
num = request.args["num"]
|
date = request.args.get["date"]
|
||||||
name = request.args.get("name")
|
warehouse_id = request.args.get("warehouse_id")
|
||||||
return "GET으로 전달된 데이터({}, {})".format(num, name)
|
# name = request.args.get("name")
|
||||||
|
# return "GET으로 전달된 데이터({}, {})".format(date, warehouse_id, quantity, name)
|
||||||
|
return "GET으로 전달된 데이터({}, {}, {})".format(date, warehouse_id, quantity)
|
||||||
else:
|
else:
|
||||||
num = request.form["num"]
|
date = request.form["date"]
|
||||||
name = request.form["name"]
|
warehouse_id = request.form["warehouse_id"]
|
||||||
return "POST로 전달된 데이터({}, {})".format(num, name)
|
quantity = request.form["quantity"]
|
||||||
|
return "POST로 전달된 데이터({}, {}, {})".format(date, warehouse_id, quantity)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
|
|||||||
@@ -5,11 +5,17 @@
|
|||||||
<h2>WMS</h2>
|
<h2>WMS</h2>
|
||||||
|
|
||||||
<form action="/method" method="POST">
|
<form action="/method" method="POST">
|
||||||
<label for="fname">사번:</label><br>
|
<label for="date">날짜</label>
|
||||||
<input type="text" id="fname" name="num"><br>
|
<input type="text" id="date" name="date" value="{{date}}"><br><br>
|
||||||
<label for="lname">이름:</label><br>
|
<label for="warehouse_id">창고</label>
|
||||||
<input type="text" id="lname" name="name"><br><br>
|
<input type="text" id="warehouse_id" name="warehouse_id" value="{{warehouse_id}}"><br><br>
|
||||||
|
<label for="name">제품명</label>
|
||||||
|
<input type="text" id="name" value="{{name}}"><br><br>
|
||||||
|
<label for="quantity">수량</label>
|
||||||
|
<input type="text" id="quantity" name="quantity" value="{{quantity}}"><br><br>
|
||||||
|
|
||||||
<input type="submit" value="확인">
|
<input type="submit" value="확인">
|
||||||
|
<input type="submit" value="취소">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user