-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
49 lines (40 loc) · 1.4 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import sys
import os
# TODO: Change prid, caid, reid to varchar(10) in models.
from flask import Flask, render_template
from flask_cors import CORS
from database import db_session
from create_database import create_database
from database import init_db
from models.category.route import category_route
from models.product.route import product_route
from models.review.route import review_route
from models.ip.route import ip_route
from models.topic.route import topic_route
from models.product_history.route import product_history_route
from log import Logger
log = Logger.get_instance()
app = Flask(__name__, static_folder='assets', template_folder='templates')
CORS(app, resources={r"/api/*": {"origins": "*"}})
# request를 마친 후 session을 닫아버리게 만듦.
@app.teardown_request
def shutdown_session(exception=None):
db_session.remove()
app.register_blueprint(category_route)
app.register_blueprint(product_route)
app.register_blueprint(review_route)
app.register_blueprint(ip_route)
app.register_blueprint(topic_route)
app.register_blueprint(product_history_route)
init_db()
@app.route('/health', methods=['GET'])
def health():
return 'OK'
@app.route('/', methods=['GET'])
def index():
return render_template('index.html')
if __name__ == '__main__':
port_num = sys.argv[1]
app.run(port=port_num)
# app.run(debug=True)
# app.run(host='0.0.0.0') # 외부 접근 가능. public IP.