일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- 쿠키
- prettier
- 자바
- 서버 통신
- 타입스크립트
- 다양한 기능
- HTTP
- Boxmodel
- 웹 렌더링
- eslint
- 동적 타입
- 프디아
- 웹 클라이언트
- 웹 스크래핑
- 웹
- jwt
- scss
- 세션
- Visual Studio Code
- 기본 타입
- 프로디지털아카데미
- 웹 기초
- 신한투자증권
- 백그라운드 실행
- gatsby.js
- CORS
- 예외 클래스
- 비동기기술
- Flask 오류
- 정적 타입
- Today
- Total
Moon Blog
사전학습 3주차 - Flask / 응답 만들기 / 파일 관리 / 다양한 기능 본문
- Flask
Micro - 마이크로 서비스
Routing - 특정 주소로 접속했을때 주소마다 다른 컨텐츠를 보여줌
Rendering -
flaks 설치시
WARNING: The script flask.exe is installed in 'C:\Users\사용자명\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
다음과 같은 경고문이 뜰 경우 환경변수 설정을 해줘야 함
윈도우 검색으로 '시스템 환경 변수 편집' 입력
다음과 같은 창이 뜨고 환경 변수 -> 사용자 변수에 'Path' 누르고 편집 클릭 -> 새로만들기 클릭 -> 'C:\Users\사용자명\AppData\Roaming\Python\Python310\Scripts' 입력 후 확인하면 오류 해결
- 서버 실행
https://flask-docs-kr.readthedocs.io/ko/latest/quickstart.html
flask 기본 애플리케이션 코드 복사 후 붙여넣기
- 응답 만들기(html, api)
flask로부터 render_template 추가
문자열 대신 html returnd은 render_template이 함
return 자리에 render_template(파일명.html)로 불러오기 가능
이때 flask는 'templates' 라는 폴더명 안에 있는 파일만 불러옴 그러므로 templates라는 폴더명을 갖는 폴더를 생성하고 그 안에 파일을 만들어야(Flask에서 정의해놓은 이름)
웹 페이지는 결과로 어떤 페이지를 주는 거고
api는 결과로 어떤 데이터를 전달함
flask로부터 jsonify 추가
api는 json 형식임으로 jsonify(딕셔너리형태)로 실
- 파일 관리
'static' 폴더 생성(Flask에서 정의해놓은 이름)
css, javascript와 이미지 등 html 관련 요소들이 위치하는 폴더
routing시 html 파일은 templates 폴더에 존재하기 때문에 <link>로 경로 지정시 '/static'이 맨 앞에 들어가야함
- 아이콘 제공 사이트
https://materialdesignicons.com/
view svg 누르고 svg 코드 복사 후 사용 가능 - 색이랑 크기 지정 가능해서 편리
- 지도 불러오기
카카오맵에서 위치 검색 후 공유에서 html 태그 복사 - 소스 생성 - 복사 후 코드에 붙여넣기
이미지를 100%로 채우기 위해서 'root_daum_roughmap' 클래스의 width를 100%로 지정
- 이미지 슬라이드
https://kenwheeler.github.io/slick/
이미지 슬라이더 제공 사이트
- 텍스트 편집기
https://quilljs.com/docs/quickstart/
텍스트 편집기 제공 사이트
- 이미지 업로드
form 태그에서 이미지를 전달하기 위해 enctype="multipart/form-data" 입력 필요
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype
python - mport os (경로 표현하는 패키지 )
- 주소 검색 기능
https://postcode.map.daum.net/guide#upgrade
기본 사용법 참고해서 활용
'신한투자증권 프로 디지털 아카데미' 카테고리의 다른 글
사전학습 4주차 - AWS / 백그라운드 실행 / 도메인 연결 (0) | 2023.01.08 |
---|---|
사전학습 2주차 - 웹 스크래핑(크롤링) / 몽고DB (0) | 2023.01.02 |
사전학습 1주차 - jQuery / 서버 통신 / API / Ajax (0) | 2023.01.01 |
사전학습 1주차 - 웹 사이트 구성 원리 / Bootstrap / CDN (0) | 2022.12.25 |