Skip to content

Commit 7868fac

Browse files
authored
Merge pull request #2 from msnodeve/release1/fix
[Merge] release1/fix -> master ; 1차 릴리즈 업데이트
2 parents 8fcd697 + e44e17a commit 7868fac

25 files changed

+364
-533
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
.venv
33

44
# vscode
5+
.DS_Store
56
.vscode
67

78
# python
89
__pycache__
910

10-
# database
11+
# testcode
12+
.pytest_cache
13+
.coverage
14+
cov_html
15+
16+
# database
17+
migrations

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
GREEN=\033[1;32;40m
2+
RED=\033[1;31;40m
3+
NC=\033[0m # No Color
4+
5+
database:
6+
@bash -c "echo -e \"${GREEN}[db orm 시작]${NC}\""
7+
python manage.py db init
8+
python manage.py db migrate
9+
python manage.py db upgrade
10+
11+
test:
12+
@bash -c "echo -e \"${GREEN}[pytest 시작]${NC}\""
13+
pipenv run pytest app/tests --cov-report=html:cov_html --cov-report=term --cov=app

Pipfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ autopep8 = "*"
1111

1212
[packages]
1313
flask = "*"
14+
flask-script = "*"
1415
flask-sqlalchemy = "*"
16+
flask-marshmallow = "*"
1517
flask-migrate = "*"
1618
pymysql = "*"
1719
flask-restplus = "*"
18-
flask-marshmallow = "*"
19-
marshmallow-jsonapi = "*"
20-
flask-script = "*"
21-
flask-basicauth = "*"
2220
pyjwt = "*"
23-
flask-bcrypt = "*"
2421

2522
[requires]
2623
python_version = "3.7"

Pipfile.lock

Lines changed: 4 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,98 @@
22

33
python 개발 환경부터 API, 게시판까지 만들기
44

5-
---
65

7-
### **What?**
6+
7+
## Develop Environments
8+
9+
***
10+
11+
- MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
12+
- Python 3.7
13+
- vscode
14+
- Docker-Compose version 1.23.2, build 1110ad01
15+
16+
17+
18+
## Develop tools
19+
20+
***
21+
22+
- pipenv = pip + virtualenv
23+
- Flask-RESTPlus = Flask-RESTful + Swagger
24+
- MySQL docker container
25+
- Docker-compose
26+
27+
28+
29+
## Project Structure
30+
31+
***
32+
33+
```txt
34+
.
35+
├── README.md
36+
├── app
37+
│ ├── __init__.py
38+
│ ├── constans.py
39+
│ ├── api
40+
│ │ ├── __init__.py
41+
│ │ ├── auth_type.py
42+
│ │ └── database.py
43+
│ ├── posts
44+
│ │ ├── __init__.py
45+
│ │ ├── models.py
46+
│ │ └── views.py
47+
│ ├── users
48+
│ │ ├── __init__.py
49+
│ │ ├── models.py
50+
│ │ └── views.py
51+
│ └── tests
52+
├── confs
53+
│ └── database
54+
│ └── mysql
55+
│ └── .env
56+
├── Pipfile
57+
├── Pipfile.lock
58+
├── Makefile
59+
├── docker-compose.yml
60+
├── .gitignore
61+
└── .envrc
62+
```
63+
64+
65+
66+
## How to run
67+
68+
***
69+
70+
```bash
71+
> docker-compose up -d
72+
> pipenv shell
73+
> pipenv install --dev
74+
> make database
75+
> python manage.py run
76+
```
77+
78+
79+
80+
## Preview
81+
82+
***
83+
84+
![api_image](/images/api_image.png)
85+
86+
87+
88+
## Release
89+
90+
- 2019년 7월 25일 1차 릴리즈 v1.0
91+
92+
93+
94+
95+
96+
### What?
897

998
> 왜 해야 하는가
1099
@@ -13,6 +102,8 @@ python 개발 환경부터 API, 게시판까지 만들기
13102
3. 백 엔드, 프론트 엔드 까지 풀 스택을 목표로
14103
4. 프로페셔널한 개발자가 되기 위해서
15104

105+
***
106+
16107
### **개인적 의견**
17108

18109
안드로이드 클라이언트만 개발하다 보니 RESTful(?) 백 엔드(?) 뭐가 뭐인지 아무것도 이해할 수도 이해할 시간도 이해할 겨를도 없었다. 처음엔 말로만 백 엔드 개발자가 되어야지 그랬지만, 이제는 다르다. 서울에 올라온 만큼 내 롤 모델 개발자 형 밑에서 열심히 공부해 많은 것을 해 보고자 한다. 본인의 입으로 "나는 개발자다"라고 말하고 다니는 이상 모르고 넘어가면 안 될 부분이 상당히 많다고 생각한다. 이 프로젝트도 그러하다. 모르는 사람들은 절대로 모를 것이다. 백 엔드 프로그래머가 되기 위해서는 기본적으로 갖추어야 할 소양이라 생각한다!
@@ -34,12 +125,18 @@ python 개발 환경부터 API, 게시판까지 만들기
34125

35126
> 언제 할 것인가
36127
37-
2019년 7월 11일부터 시작했으며 게시판을 완성할 때까지 계속할 것이다.
128+
2019년 7월 11일부터 시작했으며 게시판 API를 완성할 때까지 계속할 것이다.
129+
130+
- 2019년 7월 25일 1차 릴리즈
38131

39132
---
40133

41134
### **Who?**
42135

43136
> 누가 하는가
44137
45-
알려주시는 형과 함께하지만, 당연히 혼자 머리를 싸매고 끙끙해야겠지 !
138+
내가 한다.
139+
140+
141+
142+
이제 시작해보도록 합시다!

app/.DS_Store

-6 KB
Binary file not shown.

app/__init__.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,24 @@
11
"""
2-
app init
2+
APP을 실행하기 위해 config file
33
"""
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")
154

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
189

19-
def create_app() -> (Flask):
20-
""" create_app() 함수를 호출해 앱을 초기화 """
2110

22-
""" app config part """
23-
# 나중에 config는 다 빼야 할 것 같다.
11+
def create_app()->(Flask):
12+
""" create_app()을 호출하여 app을 초기화 """
2413
app = Flask(__name__)
2514
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
3317
app.config['SQLALCHEMY_ECHO'] = True
3418
app.config['DEBUG'] = True
19+
3520
DB.init_app(app)
3621
REST_API.init_app(app)
3722
MA.init_app(app)
38-
39-
""" return part """
23+
4024
return app

app/api/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
API config file
3+
"""
4+
15
from flask_restplus import Api
26
from app.users.views import API as users_api
37
from app.posts.views import API as posts_api
@@ -6,4 +10,4 @@
610
REST_API = Api(authorizations={**ACCESS_TOKEN, **BASIC_AUTH})
711

812
REST_API.add_namespace(users_api, '/user')
9-
REST_API.add_namespace(posts_api, '/posts')
13+
REST_API.add_namespace(posts_api, '/post')

0 commit comments

Comments
 (0)