From: insang-hmogara-pc Date: Mon, 14 Sep 2026 05:37:56 +0000 (+0900) Subject: Initial commit X-Git-Url: https://git.insang.kr/gitweb/?a=commitdiff_plain;h=3a256a813cad192e13a846b69c7557c81f228db6;p=weddingcard.git Initial commit --- 3a256a813cad192e13a846b69c7557c81f228db6 diff --git a/apiserver/app/__pycache__/app.cpython-38.pyc b/apiserver/app/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000..bd2b4fc Binary files /dev/null and b/apiserver/app/__pycache__/app.cpython-38.pyc differ diff --git a/apiserver/app/__pycache__/route.cpython-38.pyc b/apiserver/app/__pycache__/route.cpython-38.pyc new file mode 100644 index 0000000..a9a0612 Binary files /dev/null and b/apiserver/app/__pycache__/route.cpython-38.pyc differ diff --git a/apiserver/app/__pycache__/router_main.cpython-38.pyc b/apiserver/app/__pycache__/router_main.cpython-38.pyc new file mode 100644 index 0000000..dc431be Binary files /dev/null and b/apiserver/app/__pycache__/router_main.cpython-38.pyc differ diff --git a/apiserver/app/__pycache__/url.cpython-38.pyc b/apiserver/app/__pycache__/url.cpython-38.pyc new file mode 100644 index 0000000..6c8343b Binary files /dev/null and b/apiserver/app/__pycache__/url.cpython-38.pyc differ diff --git a/apiserver/app/app.py b/apiserver/app/app.py new file mode 100644 index 0000000..f72ebc1 --- /dev/null +++ b/apiserver/app/app.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'hello' \ No newline at end of file diff --git a/apiserver/app/route.py b/apiserver/app/route.py new file mode 100644 index 0000000..f72ebc1 --- /dev/null +++ b/apiserver/app/route.py @@ -0,0 +1,6 @@ +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'hello' \ No newline at end of file diff --git a/apiserver/app/router_main.py b/apiserver/app/router_main.py new file mode 100644 index 0000000..9205840 --- /dev/null +++ b/apiserver/app/router_main.py @@ -0,0 +1,7 @@ +from flask import Flask, Blueprint + +from weddingcard import router as weddingcard + +app= Flask(__name__) + +app.register_blueprint(weddingcard.app) \ No newline at end of file diff --git a/apiserver/app/url.py b/apiserver/app/url.py new file mode 100644 index 0000000..ecd0cfd --- /dev/null +++ b/apiserver/app/url.py @@ -0,0 +1,9 @@ +from flask import Flask + +from weddingcard import url as weddingcard + +app = Flask(__name__) + +@app.route('/weddingcard') +def hello_world(): + return weddingcard \ No newline at end of file diff --git a/apiserver/app/weddingcard/__pycache__/controller.cpython-38.pyc b/apiserver/app/weddingcard/__pycache__/controller.cpython-38.pyc new file mode 100644 index 0000000..b7cdf4e Binary files /dev/null and b/apiserver/app/weddingcard/__pycache__/controller.cpython-38.pyc differ diff --git a/apiserver/app/weddingcard/__pycache__/router.cpython-38.pyc b/apiserver/app/weddingcard/__pycache__/router.cpython-38.pyc new file mode 100644 index 0000000..7184092 Binary files /dev/null and b/apiserver/app/weddingcard/__pycache__/router.cpython-38.pyc differ diff --git a/apiserver/app/weddingcard/__pycache__/url.cpython-38.pyc b/apiserver/app/weddingcard/__pycache__/url.cpython-38.pyc new file mode 100644 index 0000000..7d26dca Binary files /dev/null and b/apiserver/app/weddingcard/__pycache__/url.cpython-38.pyc differ diff --git a/apiserver/app/weddingcard/controller.py b/apiserver/app/weddingcard/controller.py new file mode 100644 index 0000000..0b74819 --- /dev/null +++ b/apiserver/app/weddingcard/controller.py @@ -0,0 +1,10 @@ +from flask import Flask, Blueprint + +from guestbook import service as guestbook + +app= Flask(__name__) + +URL = Blueprint('weddingcard', __name__, url_prefix= '/weddingcard') + + +app.register_blueprint(guestbook.app) \ No newline at end of file diff --git a/apiserver/app/weddingcard/guestbook/__pycache__/service.cpython-38.pyc b/apiserver/app/weddingcard/guestbook/__pycache__/service.cpython-38.pyc new file mode 100644 index 0000000..d026492 Binary files /dev/null and b/apiserver/app/weddingcard/guestbook/__pycache__/service.cpython-38.pyc differ diff --git a/apiserver/app/weddingcard/guestbook/model.py b/apiserver/app/weddingcard/guestbook/model.py new file mode 100644 index 0000000..beb3550 --- /dev/null +++ b/apiserver/app/weddingcard/guestbook/model.py @@ -0,0 +1,8 @@ +from flask import request +from flask_restx import Resource, Api, Namespace + +api= Namespace('guestbook') + +@api.route('/') +def index(): + return 'hi' \ No newline at end of file diff --git a/apiserver/app/weddingcard/guestbook/service.py b/apiserver/app/weddingcard/guestbook/service.py new file mode 100644 index 0000000..cc95b1c --- /dev/null +++ b/apiserver/app/weddingcard/guestbook/service.py @@ -0,0 +1,19 @@ +import json +from flask import jsonify +from ..library.db import db as DB +from sqlalchemy import text + +def index(): + return DB.test() + +def get(): + return 'get' + +def post(): + return 'post' + +def put(): + return 'put' + +def delete(): + return 'delete' \ No newline at end of file diff --git a/apiserver/app/weddingcard/library/db/__pycache__/db.cpython-38.pyc b/apiserver/app/weddingcard/library/db/__pycache__/db.cpython-38.pyc new file mode 100644 index 0000000..63134ef Binary files /dev/null and b/apiserver/app/weddingcard/library/db/__pycache__/db.cpython-38.pyc differ diff --git a/apiserver/app/weddingcard/library/db/config.py b/apiserver/app/weddingcard/library/db/config.py new file mode 100644 index 0000000..0b60e1e --- /dev/null +++ b/apiserver/app/weddingcard/library/db/config.py @@ -0,0 +1,11 @@ +# /config.py + +db_weddingcard= { + 'user': 'insang', + 'password': 'Whtkd530823#', + 'host': 'localhost', + 'port': '3306', + 'database': 'weddingcard', +} + +url= "mysql+mysqlconnector://insang:Whtkd530823#@localhost:3306/weddingcard?charset=utf8mb4" \ No newline at end of file diff --git a/apiserver/app/weddingcard/library/db/db.py b/apiserver/app/weddingcard/library/db/db.py new file mode 100644 index 0000000..9d593d1 --- /dev/null +++ b/apiserver/app/weddingcard/library/db/db.py @@ -0,0 +1,26 @@ +import pymysql, json, pprint +from sqlalchemy import text + +def test(): + db_connection = pymysql.connect( + user= 'insang', + passwd= 'Whtkd530823#', + host= 'insang.duckdns.org', + db= 'weddingcard', + charset= 'utf8' + ) + cursor= db_connection.cursor(pymysql.cursors.DictCursor) + cursor.execute("select * from guestbook") + # result= json.dumps(cursor.fetchall(), ensure_ascii=True) + result= cursor.fetchall() + return MyPrettyPrinter().pprint(result) + + +class MyPrettyPrinter(pprint.PrettyPrinter): + def format(self, _object, context, maxlevels, level): + if isinstance(_object, str): + return "'%s'" % _object.encode('utf8'), True, False + elif isinstance(_object, str): + _object = str(_object, 'utf8') + return "'%s'" % _object.encode('utf8'), True, False + return pprint.PrettyPrinter.format(self, _object, context, maxlevels, level) \ No newline at end of file diff --git a/apiserver/app/weddingcard/router.py b/apiserver/app/weddingcard/router.py new file mode 100644 index 0000000..89c3b95 --- /dev/null +++ b/apiserver/app/weddingcard/router.py @@ -0,0 +1,29 @@ +from flask import request, Blueprint + +from .guestbook import service as guestbook + +app = Blueprint('weddingcard', __name__, url_prefix= '/weddingcard') + +# region guestbook section + +@app.route('/guestbook/') +def index(): + return guestbook.index() + +@app.route('/guestbook/get') +def get(): + return guestbook.get() + +@app.route('/guestbook/post') +def post(): + return guestbook.post() + +@app.route('/guestbook/put') +def put(): + return guestbook.put() +@app.route('/guestbook/delete') +def delete(): + return guestbook.delete() + +# endregion + diff --git a/apiserver/app/weddingcard/url.py b/apiserver/app/weddingcard/url.py new file mode 100644 index 0000000..cfbb7cc --- /dev/null +++ b/apiserver/app/weddingcard/url.py @@ -0,0 +1,13 @@ +from flask import Flask, Blueprint +from flask_restx import Resource, Api + +from guestbook import model as guestbook + +# region 상수 선언 +NAME_URL= __name__.split('.')[0] +# endregion + +app = Blueprint(NAME_URL, __name__, url_prefix= '/' + NAME_URL) +api = Api(app) + +api.add_namespace(guestbook, '/guestbook') \ No newline at end of file diff --git a/apiserver/wsgi/mod.wsgi b/apiserver/wsgi/mod.wsgi new file mode 100644 index 0000000..8139357 --- /dev/null +++ b/apiserver/wsgi/mod.wsgi @@ -0,0 +1,3 @@ +import sys +sys.path.insert(0, '/var/www/apiserver/app') +from router_main import app as application \ No newline at end of file