|
1 | 1 | """ |
2 | | - app init |
| 2 | + APP을 실행하기 위해 config file |
3 | 3 | """ |
4 | | -from flask import Flask, render_template, jsonify |
5 | | -from flask_restplus import Resource, Api, fields, reqparse |
6 | | -from flask_sqlalchemy import SQLAlchemy |
7 | | -from sqlalchemy.exc import SQLAlchemyError |
8 | | -from sqlalchemy.sql import text |
9 | | -from flask_marshmallow import Marshmallow |
10 | | -from app.api.database import DB |
11 | | -from app.api import REST_API |
12 | | - |
13 | | -SQLALCHEMY_DATABASE_URI = \ |
14 | | - ("mysql+pymysql://{USER}:{PASSWORD}@{ADDR}:{PORT}/{NAME}?charset=utf8") |
15 | 4 |
|
16 | | -# 설명할 API에 대한 것 |
17 | | -MA = Marshmallow() |
| 5 | +from flask import Flask |
| 6 | +from app.api.database import DB, MA |
| 7 | +from app.api import REST_API |
| 8 | +from app.constants import SQLALCHEMY_DATABASE_URI_FORMAT |
18 | 9 |
|
19 | | -def create_app() -> (Flask): |
20 | | - """ create_app() 함수를 호출해 앱을 초기화 """ |
21 | 10 |
|
22 | | - """ app config part """ |
23 | | - # 나중에 config는 다 빼야 할 것 같다. |
| 11 | +def create_app()->(Flask): |
| 12 | + """ create_app()을 호출하여 app을 초기화 """ |
24 | 13 | app = Flask(__name__) |
25 | 14 | app.app_context().push() |
26 | | - app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI.format( |
27 | | - USER="root", |
28 | | - PASSWORD="1234", |
29 | | - ADDR="127.0.0.1", |
30 | | - PORT=3306, |
31 | | - NAME="board" |
32 | | - ) |
| 15 | + |
| 16 | + app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI_FORMAT |
33 | 17 | app.config['SQLALCHEMY_ECHO'] = True |
34 | 18 | app.config['DEBUG'] = True |
| 19 | + |
35 | 20 | DB.init_app(app) |
36 | 21 | REST_API.init_app(app) |
37 | 22 | MA.init_app(app) |
38 | | - |
39 | | - """ return part """ |
| 23 | + |
40 | 24 | return app |
0 commit comments