Skip to content

๐Ÿซ ๋‹จ๊ณ„ ๋ณ„ ์‹œ๊ฐํ™”๊ฐ€ ๊ฐ€๋Šฅํ•œ ๊ต์œก ๋ชฉ์  Python ์›น ์ปดํŒŒ์ผ๋Ÿฌ

Notifications You must be signed in to change notification settings

wwlee94/online-coding-tutor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

46 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Online Coding Tutor - OCT

screenshot_1

์ฝ”๋”ฉ ๊ต์œก ์›น ํ”Œ๋žซํผ ์„œ๋น„์Šค

์„œ๋น„์Šค ๊ฐœ์š”

์ค€๋น„๋œ ๋‹ค์–‘ํ•œ ์˜ˆ์ œ๋ฅผ ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ฝ”๋“œ ์‹คํ–‰ ๋‹จ์œ„ ๋ณ„๋กœ ์‹œ๊ฐํ™”ํ•ด์ฃผ์–ด ์ง๊ด€์ ์œผ๋กœ ์ดํ•ด๋ฅผ ๋„์™€์ฃผ๋Š” ์›น ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค.

๋ˆ„๊ตฌ๋ฅผ ์œ„ํ•œ ์„œ๋น„์Šค ?

  1. ์ฝ”๋”ฉ์„ ์ฒ˜์Œ ์ ‘ํ•˜๋Š” ์‚ฌ์šฉ์ž
  2. ๋‚˜์˜ ์ฝ”๋“œ๊ฐ€ ์–ด๋–ป๊ฒŒ ์ˆœ์ฐจ์ ์œผ๋กœ ์‹คํ–‰๋˜๋Š”์ง€ ๊ถ๊ธˆํ•ดํ•˜๋Š” ์‚ฌ์šฉ์ž
  3. Python ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ๋”ฐ๋กœ ์„ค์น˜ํ•  ํ•„์š”์—†์ด ์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ ์‹œํ‚ค๊ณ  ์‹ถ์€ ์‚ฌ์šฉ์ž

์‹คํ–‰ ํ™”๋ฉด

screenshot_3

๊ตฌํ˜„ ์‚ฌํ•ญ

์„œ๋ฒ„ ( Backend )

  1. Python๊ณผ Flask ๊ตฌ์ถ•ํ•œ ๋ฐฑ ์—”๋“œ ์„œ๋ฒ„๋Š” WebSocket์œผ๋กœ ํ†ต์‹ ํ•˜๋„๋ก Socket.IO๋ฅผ ์ด์šฉํ•˜์—ฌ ์›น ๋ธŒ๋ผ์šฐ์ €์™€ ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„
  2. Python Bdb ๋””๋ฒ„๊น… ํˆด์„ ์ด์šฉํ•˜์—ฌ ๋ณ€์ˆ˜ํƒ€์ž…, ๋ณ€์ˆ˜๋ช…, ํ•จ์ˆ˜ ๋“ฑ๋“ฑ์„ ๊ฐ€์ ธ์™€ ๋ฐ์ดํ„ฐ ํŒŒ์‹ฑ
  3. Docker ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์ด์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ - SandBoxing ๊ตฌํ˜„
  4. AWS EC2 ์ธ์Šคํ„ด์Šค์— ์„œ๋ฒ„๋ฅผ ๋ฐฐํฌ
  5. AWS ELB (๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ) + AWS ROUTE 53์„ ์‚ฌ์šฉํ•˜์—ฌ Scale-Out ํšจ๊ณผ์™€ DNS ๊ด€๋ฆฌ ๊ธฐ๋Šฅ ๊ตฌํ˜„

ํด๋ผ์ด์–ธํŠธ ( Client )

  1. ์„œ๋ฒ„์—์„œ ํŒŒ์‹ฑํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„ GoJS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ์‹œ๊ฐํ™” ๊ตฌํ˜„
  2. CodeMirror ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํด๋ผ์ด์–ธํŠธ์—์„œ ์ฝ”๋“œ ์ž‘์„ฑ, ์ˆ˜์ • ๋ฐ ์ฝ”๋“œ ์ œ์ถœ ๊ฐ€๋Šฅ
  3. ์‚ฌ์šฉ์ž์—๊ฒŒ ์—ฌ๋Ÿฌ ๊ธฐ๋Šฅ๋“ค์„ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก View ๊ตฌํ˜„

์ฃผ์š” ๊ธฐ๋Šฅ

  1. Python ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘์„ฑ๋˜์–ด ์ฝ”๋“œ ์‹คํ–‰ ๋‹จ์œ„๋ณ„ ์‹œ๊ฐํ™” ๊ธฐ๋Šฅ
  2. ์‚ฌ์šฉ์ž๊ฐ€ ์ฝ”๋“œ๋ฅผ ์ง์ ‘ ์ž‘์„ฑ ํ›„ ์‹คํ–‰์‹œ์ผœ ์‹ค์‹œ๊ฐ„ ์‹œ๊ฐํ™”ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณต
  3. ์ฝ”๋“œ๋ฅผ ์ปดํŒŒ์ผํ•ด ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๊ธฐ๋Šฅ
  4. Pdb ๋””๋ฒ„๊น… ํˆด์„ ์ด์šฉํ•œ ๋””๋ฒ„๊น… ๊ธฐ๋Šฅ ์ œ๊ณต
  5. ๊ฐœ๋ฐœํ™˜๊ฒฝ ์„ค์ • ํ•„์š” ์—†์ด ์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ํ”Œ๋žซํผ์„ ์ œ๊ณต

Reference

์‹คํ–‰ ๋ฐฉ๋ฒ•

  • Docker ์„ค์น˜
  • ./docker/Dockerfile์„ ๊ฐ€์ง€๊ณ  oct-container ๋ผ๋Š” ์ด๋ฏธ์ง€ ์ƒ์„ฑ
    • COMMAND : docker build --tag oct-container .
  • docker-py ๋ชจ๋“ˆ ์„ค์น˜
  • eventlet ๋ชจ๋“ˆ ์„ค์น˜
  • python2 ./server.py ์‹คํ–‰

Visualize

  1. Python 2.7 ๋ฒ„์ „ ๊ธฐ๋ฐ˜์œผ๋กœ ์ฝ”๋“œ ์‹œ๊ฐํ™”
  2. ๋…ธ๋“œ ํด๋ฆญ์‹œ ํ•ด๋‹น ๋…ธ๋“œ๊ฐ€ Pointing ํ•˜๋Š” ๋ชจ๋“  ๋…ธ๋“œ๋“ค์„ ํ•˜์ด๋ผ์ดํŠธ ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ

๋…ธ๋“œ๊ฐ€ ์–ด๋–ค ๋…ธ๋“œ๋“ค์„ ๊ฐ€๋ฅดํ‚ค๋Š”์ง€ ํ™•์ธ ๊ฐ€๋Šฅ

  1. ๋งˆ์šฐ์Šค ํด๋ฆญ ํ›„ ๋“œ๋ž˜๊ทธํ•ด์„œ Diagram ์ด๋™ ๊ฐ€๋Šฅ
  2. ์ง„ํ–‰ ์ƒํ™ฉ์˜ ์ฒ˜์Œ, ์ด์ „, ๋‹ค์Œ, ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ ์ œ๊ณต

Run

  • Python2.7, Python3.6 ๋ฒ„์ „ ์ง€์›
  • Docker ๊ฐ€์ƒ ํ™˜๊ฒฝ์—์„œ ์ฝ”๋“œ ์ปดํŒŒ์ผ & ์‹คํ–‰ (SandBoxing)
  • ๋ชจ๋“ˆ Import ๊ธฐ๋Šฅ ์ œ๊ณต (Python2,3 ๊ธฐ๋ณธ ๋ชจ๋“ˆ - re, random, math ๋“ฑ๋“ฑ )
  • ์›ํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•ด ๊ฒฐ๊ณผ ํ™•์ธ ๊ฐ€๋Šฅ

Debug

AWS EC2 - Ubuntu ์„œ๋ฒ„ ์ •๋ณด

  • Version : Ubuntu 18.04.3 LTS
  • CPU Model : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
  • Memory : 1GB

Docker Container ์ •๋ณด

  • Python2.7, Python3.6 ๋นŒ๋“œ
  • CPU Limit - CPU ์ž์› ์ œํ•œ ํฌ๊ธฐ (Default : CPU 1๊ฐœ ํ• ๋‹น)
  • Memory Limit - ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ ํฌ๊ธฐ (Default : 64๋ฉ”๊ฐ€)
  • IO Access Limit : READ_ONLY (์ฝ๊ธฐ๋งŒ ๊ฐ€๋Šฅ)

์ œ์•ฝ ์‚ฌํ•ญ

Visualize

  • class, range, closur, decorator(@), unpack(*)

    ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค

  • ์ฝ”๋“œ ๋‹จ๊ณ„๋Š” 250 ๋‹จ๊ณ„ ์ œํ•œ

    250 ๋‹จ๊ณ„๋ฅผ ๋„˜์–ด์„œ๋Š” ์ฝ”๋“œ๋Š” ์‹คํ–‰ ์ œํ•œ

  • global string ๊ธธ์ด ์ œํ•œ
  • object string ๊ธธ์ด ์ œํ•œ

๊ณตํ†ต

TabError: inconsistent use of tabs and spaces in indentation

  • ํ•ด๋‹น ์—๋Ÿฌ๋Š” ๋“ค์—ฌ์“ฐ๊ธฐ ์—๋Ÿฌ์— ํ•ด๋‹น๋ฉ๋‹ˆ๋‹ค.
  • python style guid(pep8)์—์„œ๋Š” ๋“ค์—ฌ์“ฐ๊ธฐ = 4 spaces ๋กœ ๊ทœ์ •ํ•ด๋†“์•˜์œผ๋‹ˆ ์ด๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

๋ฌธ์˜ ์‚ฌํ•ญ

Email : [email protected] ์œผ๋กœ ์—ฐ๋ฝ์ฃผ์„ธ์š”.

About

๐Ÿซ ๋‹จ๊ณ„ ๋ณ„ ์‹œ๊ฐํ™”๊ฐ€ ๊ฐ€๋Šฅํ•œ ๊ต์œก ๋ชฉ์  Python ์›น ์ปดํŒŒ์ผ๋Ÿฌ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published