2nd-wanted-pre-onboarding-team-A / Human-Scape-Wanted-A

ํœด๋จผ์Šค์ผ€์ดํ”„ ๊ธฐ์ˆ  ๊ณผ์ œ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์ž…๋‹ˆ๋‹ค. ๋ฐฐ์น˜ ์Šค์ผ€์ฅด๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๊ณต๊ณต API ๋ฐ์ดํ„ฐ๋ฅผ ์Šคํฌ๋ž˜ํ•‘ํ•˜์—ฌ DB์— ์ ์žฌํ•˜๊ณ  ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”์ถœํ•ด ๋ด…์‹œ๋‹ค.
0 stars 1 forks source link

1_ePn61nZEatSdCPKVl5yxZQ

๐Ÿ‘ฉโ€๐Ÿ’ป Team

์ด๋ฆ„ Github ๋‹ด๋‹น ์—ญํ• 
์–‘์ˆ˜์˜ tasddc1226 DB Modeling, ์ˆ˜์ง‘ ์Šคํฌ๋ฆฝํŠธ(batch task)์ž‘์„ฑ ๋ฐ Logging ๋กœ์ง ์ž‘์„ฑ
๊ถŒ์€๊ฒฝ fore0919 ์ตœ๊ทผ ์ผ์ฃผ์ผ๋‚ด์— ์—…๋ฐ์ดํŠธ ๋œ ์ž„์ƒ์ •๋ณด ๋ฆฌ์ŠคํŠธ view, ์ž„์ƒ์ •๋ณด ๊ฒ€์ƒ‰ ๋ฐ Detail view, API ๋ฌธ์„œํ™”
์œค์ƒ๋ฏผ redtea89 Docker ๋ฐฐํฌ ๋ฐ ๋ฌธ์„œํ™”, ์ˆ˜์ง‘ ์Šคํฌ๋ฆฝํŠธ(batch task) ์ž‘์„ฑ, ๊ฐ€์‚ฐ์  ๊ธฐ๋Šฅ ๊ตฌํ˜„, ์‹คํ–‰ Guide ์ž‘์„ฑ

ใ…ค๐Ÿ‘ช ใ…ค๊ณต๋™์ž‘์—… : ๊ณต๊ณต API ๋ฐ ์š”๊ตฌ์‚ฌํ•ญ ๋ถ„์„

ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ ๊ธฐ๊ฐ„ 2022.05.10 09:00 ~ 2022.05.13 18:00

Team-A-notion

์‚ฌ์šฉ ๊ธฐ์ˆ 

Pythonใ…คDjangoใ…คMySQLใ…คDockerใ…คPostmanใ…คGitHub

๊ฐœ์ธ๋ณ„ ๊ตฌํ˜„๋ฐฉ๋ฒ• ๋ฐ ์–ด๋ ค์› ๋˜ ์ 

ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰๋ฐฉ๋ฒ•

๋กœ์ปฌํ™˜๊ฒฝ์—์„œ ์ด ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰์‹œํ‚ค๋ ค๋ฉด Django SECRET_KEY์™€ API KEY๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ์ด ์‹คํ–‰๋ฐฉ๋ฒ•์€ KEY๋ฅผ ์•Œ๊ณ  ์žˆ๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ์ž‘์„ฑ๋˜์—ˆ๋‹ค. (ํŒ€์›์ค‘ window์‚ฌ์šฉ์ž๊ฐ€ ์—†์–ด mac๋งŒ ์ž‘์„ฑ)
MAC OS

1๋ฒˆ. ํ„ฐ๋ฏธ๋„์—์—์„œ ํ”„๋กœ๊ทธ๋žจ์„ ๋‚ด๋ ค๋ฐ›์„ ํด๋”๋กœ ์ด๋™ํ•œ๋‹ค. (Documents ๋””๋ ‰ํ„ฐ๋ฆฌ ์˜ˆ์‹œ)

% cd ~/Documents

2๋ฒˆ. git clone์œผ๋กœ ํŒŒ์ผ์„ ๋ฐ›๊ณ  ํ”„๋กœ์ ํŠธ ํด๋”๋กœ ์ด๋™ํ•œ๋‹ค.

% git clone https://github.com/2nd-wanted-pre-onboarding-team-A/Human-Scape-A.git
% cd Human-Scape-A

3๋ฒˆ. ํด๋” ํŠธ๋ฆฌ ํ™•์ธ

% ls

# ์˜ˆ์‹œ ํ™”๋ฉด
README.md   human     requirements.txt
__pycache__   manage.py   research
core      dockerfile    paper
์•ž์œผ๋กœ ์ด ๋””๋ ‰ํ„ฐ๋ฆฌ์˜ ์ƒํƒœ๋ฅผ "ํ”„๋กœ์ ํŠธ ํด๋”"๋ผ ๋ถ€๋ฅด๊ฒ ๋‹ค.

4๋ฒˆ. ํŒŒ์ด์ฌ ์„ค์น˜ ํ™•์ธ

% python --version

# ์˜ˆ์‹œํ™”๋ฉด
Python 3.8.10
๋งŒ์•ฝ ํŒŒ์ด์ฌ 3.8์ด์ƒ์ด ์„ค์น˜๋˜์–ด์žˆ์ง€ ์•Š๋‹ค๋ฉด ๋งํฌ ๋กœ ์ด๋™ํ•˜์—ฌ ํŒŒ์ด์ฌ 3.8.10 (ํ˜น์€ 3.8.12) ๋ฅผ ์„ค์น˜ํ•œ๋‹ค.

5๋ฒˆ. (ํŒŒ์ด์ฌ ์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ๋‹ค๋ฉด 3๋ฒˆ ํด๋” ์œ„์น˜์—์„œ) ๊ฐ€์ƒํ™˜๊ฒฝ ์ƒ์„ฑ

% python -m venv venv

6๋ฒˆ. ๊ฐ€์ƒํ™˜๊ฒฝ ์ง„์ž…

% source venv/bin/activate

7๋ฒˆ. ํŒŒ์ด์ฌ ๋ชจ๋“ˆ ์„ค์น˜

% pip install --upgrade pip
% pip install -r requirements.txt
์—ฌ๊ธฐ์„œ ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค๋ฉด 3๋ฒˆ๋ถ€ํ„ฐ ์ •์ƒ์ ์œผ๋กœ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜์—ฌ์•ผ ํ•œ๋‹ค.

8๋ฒˆ. ํ™˜๊ฒฝ๋ณ€์ˆ˜ ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ

ํ”„๋กœ์ ํŠธ ํด๋”์—์„œ ํŒŒ์ผ๋ช… my_settings.py๋ฅผ ๋งŒ๋“ค๊ณ  ์•„๋ž˜์˜ ๋‚ด์šฉ์„ ๋ถ™์—ฌ๋„ฃ๊ธฐํ•œ๋‹ค. (KEY ๋‚ด์šฉ์€ ์ด๋ฏธ ์•Œ๊ณ  ์žˆ๋Š” ๋‚ด์šฉ์„ ์ง‘์–ด๋„ฃ์œผ๋ฉด ๋œ๋‹ค.)
# my_settings.py

DATABASES = {
    'default' : {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'human',
        'USER': 'root',
        'PASSWORD': 'mysecretpassword',
        'HOST': 'localhost',
        'PORT': '3306',
    'OPTIONS': {'charset': 'utf8mb4'}
    }
}

SECRET_KEY = ''
DEBUG = True

OPEN_API_SECRET_KEY = ''
OPEN_API_SECRET_KEY_CHALLENGE = ''

9๋ฒˆ. ๋กœ์ปฌ ํ™˜๊ฒฝ์— Mysql ์„ค์น˜

์ด๋ฏธ Mysql์ด ์„ค์น˜๋˜์–ด์žˆ๋‹ค๋ฉด ์ด ๊ณผ์ •์€ ๋„˜์–ด๊ฐ€๋„ ๋œ๋‹ค. ๋งŒ์•ฝ brew๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค๋ฉด ์ด๊ณณ์„ ์ฐธ๊ณ 
% brew install mysql
% brew services start mysql
๋ฃจํŠธ ๋น„๋ฐ€๋ฒˆํ˜ธ ์„ธํŒ… (์ด๊ณณ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ 8๋ฒˆ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ์— ๋“ค์–ด๊ฐ€์•ผํ•œ๋‹ค.)
% mysqladmin -u root password 'mysecretpassword'
ํ„ฐ๋ฏธ๋„์—์„œ mysql ์ ‘์†ํ™•์ธ(ํ„ฐ๋ฏธ๋„ ์•„๋ฌด์œ„์น˜์—์„œํ•ด๋„ ์ƒ๊ด€์—†์Œ)
% mysql -u root -p
% mysecretpassword

10๋ฒˆ. database ์ƒ์„ฑ

mysql์— ์ ‘์†ํ•˜์˜€๋‹ค๋ฉด ํ„ฐ๋ฏธ๋„ ๋ช…๋ น์ฐฝ์ด ์•„๋ž˜์™€ ๊ฐ™์ด mysql> ๋กœ ๋ฐ”๋€๋‹ค.
mysql> create database human character set utf8mb4 collate utf8mb4_general_ci;

11๋ฒˆ. Django๋ฅผ ์ด์šฉํ•œ Mysql DB ํ…Œ์ด๋ธ” ์ƒ์„ฑ

ํ”„๋กœ์ ํŠธ ํด๋”(3๋ฒˆ ์ฐธ๊ณ )๋กœ ์ด๋™ํ•˜์—ฌ ์•„๋ž˜์™€ ๊ฐ™์ด ์ž…๋ ฅ
% python manage.py migrate

12๋ฒˆ. Django ์„œ๋ฒ„ ์‹คํ–‰

ํ”„๋กœ์ ํŠธ ํด๋”์—์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.
% python manage.py runserver --noreload

13๋ฒˆ. ๋กœ์ปฌ APIํ…Œ์ŠคํŠธ

ํ„ฐ๋ฏธ๋„์—์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•œ๋‹ค. ์ž์„ธํ•œ APIํ…Œ์ŠคํŠธ๋Š” ์•„๋ž˜ API Documentation ์ฐธ๊ณ 
curl http://localhost:8000/api/v1/research

API Documentation