๋ฐ˜์‘ํ˜•

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ 407

[์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ] ์›นํŒฉ์ด๋ž€?

์›นํŒฉ(Webpack)์€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(JS) ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์œ„ํ•œ ์ •์  ๋ชจ๋“ˆ ๋ฒˆ๋“ค๋Ÿฌ์ž…๋‹ˆ๋‹ค. ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ตฌ์„ฑํ•˜๋Š” ์ž์›(HTML, CSS, ์ด๋ฏธ์ง€, JS ํŒŒ์ผ ๋“ฑ)์„ ๋ชจ๋‘ ๋ชจ๋“ˆ๋กœ ๋ณด๊ณ , ์ด๋Ÿฌํ•œ ๋ชจ๋“ˆ๋“ค์„ ์˜์กด์„ฑ ๊ทธ๋ž˜ํ”„๋กœ ๋งŒ๋“ค์–ด ํ•˜๋‚˜ ๋˜๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฒˆ๋“ค๋กœ ๊ฒฐํ•ฉํ•˜๋Š” ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ์›นํŒฉ์„ ์‚ฌ์šฉํ•จ์œผ๋กœ์จ ๊ฐœ๋ฐœ์ž๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ชจ๋“ˆ ๋ฐฉ์‹์œผ๋กœ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๊ณ , ์ตœ์ข…์ ์œผ๋กœ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํ˜•ํƒœ๋กœ ์ž์›๋“ค์„ ๋ฒˆ๋“ค๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์›นํŒฉ์˜ ์ฃผ์š” ๊ธฐ๋Šฅ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค: ๋กœ๋”(Loaders): ์›นํŒฉ์€ ์˜ค์ง ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์™€ JSON ํŒŒ์ผ๋งŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋กœ๋”๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์›นํŒฉ์ด ๋‹ค๋ฅธ ํƒ€์ž…์˜ ํŒŒ์ผ๋“ค์„ ์ฒ˜๋ฆฌํ•˜์—ฌ ๋ชจ๋“ˆ๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, CSS, ์ด๋ฏธ์ง€, HTML ํŒŒ์ผ๋“ค์„ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ชจ๋“ˆ๋กœ ๋ณ€ํ™˜..

fastAPI pydamic์œผ๋กœ ์Šคํ‚ค๋งˆ ์„ค์ •ํ•˜๊ธฐ

schema.py ์— Pydantic ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์š”์ฒญ ๋ฐ ์‘๋‹ต ์Šคํ‚ค๋งˆ๋ฅผ ์ •์˜ ์˜ˆ์‹œ: from pydantic import BaseModel from typing import Optional class JapaneseBase(BaseModel): type: Optional[str] = None letter: str pronounciation: str audio: Optional[str] = None lesson: Optional[int] = None img: Optional[str] = None # ์„ ํƒ์  ํ•„๋“œ vid: Optional[str] = None # ์„ ํƒ์  ํ•„๋“œ class JapaneseCreate(JapaneseBase): pass ๋‹ค์‹œ routers/ ํด๋”์˜ ํ•ด๋‹น ํŒŒ์ผ๋กœ๊ฐ€์„œ, ๋ผ์šฐํ„ฐ์— ..

FastAPI ์—์„œ ์˜์กด์„ฑ ์ฃผ์ž… ์ด๋ž€? (Dependency Injection)

FastAPI์˜ "Dependency Injection"์€ FastAPI ํ”„๋ ˆ์ž„์›Œํฌ์—์„œ ์ œ๊ณตํ•˜๋Š” ํ•ต์‹ฌ ๊ธฐ๋Šฅ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค. Dependency Injection์€ ์˜์กด์„ฑ ์ฃผ์ž…์ด๋ผ๊ณ ๋„ ํ•˜๋ฉฐ, ์ด๋Š” ์ฝ”๋“œ์˜ ๊ฒฐํ•ฉ๋„๋ฅผ ๋‚ฎ์ถ”๊ณ , ์œ ์ง€๋ณด์ˆ˜์™€ ํ…Œ์ŠคํŠธ๊ฐ€ ์šฉ์ดํ•˜๋„๋ก ๋„์™€์ฃผ๋Š” ์„ค๊ณ„ ํŒจํ„ด์ž…๋‹ˆ๋‹ค. FastAPI์—์„œ๋Š” ์ด๋ฅผ ํ†ตํ•ด ๋”์šฑ ๊น”๋”ํ•˜๊ณ  ํšจ์œจ์ ์œผ๋กœ API๋ฅผ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.(์žฌ์‚ฌ์šฉ์„ฑ, ํšจ์œจ์„ฑ ์ฆ๊ฐ€์˜ ํšจ๊ณผ) Dependency Injection์˜ ๊ธฐ๋ณธ ์›๋ฆฌ FastAPI์—์„œ Dependency Injection์„ ์‚ฌ์šฉํ•˜๋ฉด, ํ•จ์ˆ˜๋‚˜ ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ง์ ‘ ์ƒ์„ฑํ•˜์ง€ ์•Š๊ณ , FastAPI๊ฐ€ ์‹คํ–‰ ์‹œ๊ฐ„(runtime)์— ์˜์กด์„ฑ์„ ์ฃผ์ž…ํ•ด์ค๋‹ˆ๋‹ค. ์ด๋กœ์จ, ํ•„์š”ํ•œ ๊ฐ์ฒด๋‚˜ ์„ค์ •, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—ฐ๊ฒฐ ๋“ฑ์„ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ณ  ์žฌ์‚ฌ์šฉํ•  ..

fastapi๋กœ ๋ผ์šฐํ„ฐ ์ž‘์„ฑ ์–ด๋–ป๊ฒŒ ํ• ๊นŒ

์˜ˆ์ œ์—์„œ ๋ณธ ๋ฐฉ์‹(alemdic ์‚ฌ์šฉ) https://github.com/tiangolo/full-stack-fastapi-template/tree/master/backend/app router = APIRouter( prefix="/", ) @router.get("/list")# /list ๊ฒฝ๋กœ๋กœ GET ์š”์ฒญ์ด ๋“ค์–ด์˜ค๋ฉด question_list ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. def question_list(): db = SessionLocal() _question_list = db.query(Question).order_by(Question.create_date.desc()).all() db.close() return _question_list ๋‹จ์  : ์‹ค์ œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„ธ์…˜์„ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ..

fastapi ์—์„œ alembic ์‚ฌ์šฉํ•˜๊ธฐ

SQLAlchemy + pydamic ๋ณด๋‹ค๋Š” SQLAlchemy+ alembic๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ถ”์„ธ. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ตฌ์กฐ ๋ณ€๊ฒฝ์ด ๋” ์‰ฝ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. Alembic์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ณผ์ •์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ช‡ ๋‹จ๊ณ„๋กœ ๋‚˜๋‰ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ์ดˆ๊ธฐ ์„ค์ •, ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ์Šคํฌ๋ฆฝํŠธ์˜ ์ƒ์„ฑ, ๊ทธ๋ฆฌ๊ณ  ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์˜ ์ ์šฉ์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. SQLAlchemy ๋ชจ๋ธ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด, ๋จผ์ € Alembic ์„ค์ •์„ ์™„๋ฃŒํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ํ›„, ๋ชจ๋ธ์— ๋Œ€ํ•œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋ฐ˜์˜ํ•˜๋Š” ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Alembic ์„ค์ •: ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ์—์„œ $ pip install alembic ; alembic init alembic ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜์—ฌ Alembic์„ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ..

fastAPI ๋กœ ๋ฐฑ์—”๋“œ ์‹œ์ž‘ํ•˜๊ธฐ (ํ™˜๊ฒฝ ์„ธํŒ…, ํด๋” ๊ตฌ์กฐ, mysql ์‚ฌ์šฉ)

flask๋ฅผ ์จ๋ดค๋‹ค๋ฉด ์กฐ๊ธˆ ์ต์ˆ™ํ•  ์ˆ˜๋„ ์žˆ๋‹ค. ์˜ˆ์‹œ ์ฐธ๊ณ  https://github.com/tiangolo/full-stack-fastapi-template GitHub - tiangolo/full-stack-fastapi-template: Full stack, modern web application template. Using FastAPI, React, SQLModel, Post Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more. - tiangolo/full-stack-fastapi-template git..

mysql ์—์„œ username ์ƒ์„ฑํ•˜๊ณ  ๊ถŒํ•œ์ฃผ๊ธฐ

ํ…Œ์ŠคํŠธ๋ฅผํ•˜๋ ค๋ฉด ๋ฃจํŠธ๋ณด๋‹ค๋Š” ์œ ์ €๋ฅผ ์ƒ์„ฑํ•ด์„œ ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. mysql์—์„œ user๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ๋ฐฉ๋ฒ•์€ ์•„๋ž˜๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. CREATE USER 'username'@'host' IDENTIFIED BY 'password'; ์—ฌ๊ธฐ์„œ Your password does not satisfy the current policy requirements. ๋ผ๋Š” ์—๋Ÿฌ๊ฐ€ ๋‚  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ ๋•Œ๋ฌธ์ธ๋ฐ SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+-------+ | Variable_name | Value | +--------------------------------------+-------+ | ..

TypeORM์„ ์‚ฌ์šฉํ•œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์ด๋ž€

๊ธฐ๋ณธ์ ์ธ ์ •๋ณด ์–ป๊ธฐ https://typeorm.io/ TypeORM - Amazing ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, typeorm.io TypeORM์„ ์‚ฌ์šฉํ•œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์€ TypeORM์ด ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์Šคํ‚ค๋งˆ๋ฅผ ๋ฒ„์ „ ๊ด€๋ฆฌํ•˜๋Š” ํ”„๋กœ์„ธ์Šค์ž…๋‹ˆ๋‹ค. ์ด๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ์ด ๋ณ€๊ฒฝ๋  ๋•Œ๋งˆ๋‹ค ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์Šคํ‚ค๋งˆ๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค๋‹ˆ๋‹ค. ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์Šคํ‚ค๋งˆ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ฝ”๋“œ ํ˜•ํƒœ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ด๋Ÿฌํ•œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋ฒ„์ „๋ณ„๋กœ ์ถ”์ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. TypeORM ..

<1> ๊ฐ„๋‹จํ•œ ์›น์‚ฌ์ดํŠธ ๋งŒ๋“ค๊ธฐ nextjs, react

https://ui.shadcn.com/์—์„œ ์„ค์น˜ https://ui.shadcn.com/docs/installation/next Next.js Install and configure Next.js. ui.shadcn.com vscode extension ์„ค์น˜ - ๊ฐ„๋‹จํ•œ ๋ช…๋ น์–ด๋กœ ์ฝ”๋“œ ์ž‘์„ฑ ๊ฐ€๋Šฅ (auth)ํด๋”์— sign-in . sign-upํด๋” ์ถ”๊ฐ€ (root) meeting [id] - dynamic routes (์ฐธ๊ณ : https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes) (home) page.tsx, layout.tsx extension์„ค์น˜ 1. ES7+ React/Redux/React-Native snip..

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ์ฐจ์ด, ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ๊ธฐ์ดˆ

ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ : ํƒ€์ž…์„ ๋ช…์„ธํ•œ๋‹ค. ํƒ€์ž…์˜ค๋ฅ˜๋ฅผ ์‰ฝ๊ฒŒ ์ฐพ์„ ์ˆ˜ ์žˆ๊ณ  ์œ ํšจ์„ฑ ๊ฒ€์ฆ์— ์šฉ์ด 1. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ function greet(name) { return "Hello, " + name + "!"; } console.log(greet("John")); 2. ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ - ํŒŒ๋ผ๋ฏธํ„ฐ, ๋ฆฌํ„ด๊ฐ’์˜ ํƒ€์ž…์„ ๋ช…์„ธ function greet(name: string): string { return "Hello, " + name + "!"; } console.log(greet("John")); [ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ๊ธฐ์ดˆ ๋ฌธ๋ฒ•] ๋ณ€์ˆ˜ ์„ ์–ธ: ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ๋•Œ๋Š” let ๋˜๋Š” const ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค let num: number = 10; const message: string = "Hello,World!"; ํ•จ์ˆ˜ ์„ ์–ธ: ํ•จ..

๋ฐ˜์‘ํ˜•