[Flask] VScode에서 flask 사용(Windows)

1. Visual Studio Code 설치


https://code.visualstudio.com/download

Download Visual Studio Code - Mac, Linux, Windows

Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.

code.visualstudio.com

 
 
 

2. VS code 실행 후 extension 탭에서 python 설치


 
 
 

3. anaconda 설치


https://www.anaconda.com/download

Free Download | Anaconda

Anaconda's open-source Distribution is the easiest way to perform Python/R data science and machine learning on a single machine.

www.anaconda.com

 
 
 

4. flask 설치


아나콘다 프롬프트 열어보기

윈도우 아이콘-> 검색 -> Anaconda PowershellPrompt

 
 
프롬프트에서 가상환경 생성

conda create -n <가상환경 이름> python=<python 버전>

 
 
가상환경 활성화

conda activate <가상환경 이름>

 
 
프롬프트에서 pip install flask를 통해 flask 설치

pip install flask

 
 
 

5. Window Powershell


'관리자권한'으로 실행

Set-ExecutionPolicyUnrestricted

 
 
 

6. VS code에서 interpreter 선택


F1 키를 누른 후 interpreter 검색한 후 python: Select Interpreter 선택

 
방금 생성한 가상환경 선택
 
 
 

7. VS code에서 encoding 확인


설정에 들어간 후 encoding에서 UTF-8인지 확인

 
 
 

8. flask 실행


terminal 탭에서 new terminal 선택

 
 
command prompt 선택

 
 
터미널에서 flask run을 실행함 (flask 파일 이름은 app.py로 작성)

 
 
127.0.0.1:5000주소로접속해야함