Flask는 파이썬 기반 웹어플리케이션 프레임워크이다.
Pocco라 불리는 파이썬 그룹을 리드하는 Armin Ronacher 에 의해 개발되었다.
Flask는 Werkzeug WSGI, Jinja2 템플릿 엔진 기반이며 둘다 Pocco 프로젝트이다.

WSGI
WSGI(Web Server Gateway Interface)는 파이썬 표준 웹어플리케이션으로 채택되었다.
WSGI는 웹 서버와 웹 응용 프로그램 간의 범용 인터페이스 사양이다.

Werkzeug
requests, response 객체와 그 외 유틸 함수를 구현한 WSGI 툴킷이다.
이를 통해 웹 프레임워크를 구축할 수 있다. 
Flask 프레임워크는 Werkzeug를 기반 중 하나로 사용한다.

Jinja2
Jinja2는 Python용으로 널리 사용되는 템플릿 엔진이다. 웹 템플릿 시스템은 템플릿을 특정 데이터 소스와 결합하여 동적 웹 페이지를 렌더링한다.

Flask는 마이크로 프레임워크라고도 한다.
애플리케이션의 핵심을 단순하면서도 확장 가능하게 유지하는 것이 목표다. 
Flask에는 데이터베이스 처리를 위한 기본 제공 추상화 계층이 없으며 검증 지원을 구성하지 않는다.
대신 Flask는 이러한 기능을 응용 프로그램에 추가하는 확장을 지원한다.

 

https://www.tutorialspoint.com/flask/flask_overview.htm

 

Flask – Overview

Flask – Overview What is Web Framework? Web Application Framework or simply Web Framework represents a collection of libraries and modules that enables a web application developer to write applications without having to bother about low-level details suc

www.tutorialspoint.com

 

'파이썬' 카테고리의 다른 글

selenium 모듈 사용  (0) 2020.04.13
파이썬 크롤링  (0) 2020.01.24
강좌 노트 정리(old)  (0) 2015.06.28

selenium 모듈의 용도는 웹페이지 테스트 자동화용 모듈

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
import time


사전 준비:
- selenium 모듈 설치: 아나콘다 네비 > environments > selenium 검색 > 설치 
- 크롬 드라이버 다운로드

 
chrome_driver = '/user/.../chromedriver'
driver = webdriver.Chrome(chrome_driver)
driver.get('https://www.python.org')
driver.find_element_by_id('id-search-field')
search.clear()
search.send_keys('lambda')
search.send_keys(Keys.RETURN)
time.sleep(2)
driver.close()


src = driver.page_source
soup = BeautifulSoup(src)

'파이썬' 카테고리의 다른 글

Flask - Overview  (0) 2022.03.16
파이썬 크롤링  (0) 2020.01.24
강좌 노트 정리(old)  (0) 2015.06.28

from bs4 import BeautifulSoup
html = <...>
soup = BeautifulSoup(html)
soup.find('h3')
soup.find('p')
soup.find('div', custom='nice')
soup.find('div', class_='test')

attrs = {'id':'upper', 'class':'test'}
soup.find('div', attrs=attrs)

soup.find_all('div')

tag = soup.find('h3')
tag.get_text()
tag.get_text().strip()

 

 

정규표현식
import re
soup.find_all('h3') h1,h2,h3...
soup.find(all(re.compile('h\d'))
back슬래시를 이용해 h가 들어가는 태그를 찾음

soup.find_all('img')
//gif확장자를 쓴 이미지를 찾고 싶다면,
soup.find_all('img', attrs={'src':re.compile('.+\.gif')})

soup.find_all('h3', class_=re.compile('.+view$'))

 

prefix [name^='test']

suffix [name $='test']

substring [name *='test']

n번째 자식tag :nth-child(n)   

- ex) h1:nth-child(2)

'파이썬' 카테고리의 다른 글

Flask - Overview  (0) 2022.03.16
selenium 모듈 사용  (0) 2020.04.13
강좌 노트 정리(old)  (0) 2015.06.28


1.

파이썬은 C로 출발


대표적 해킹 언어


장고 - 웹서버 (파이썬) ?


다른 언어에 비해 간결 100줄 -> 20줄


수학적 개념


언어 대화식(high-level, interpreted, interactive, 객체지향, scripting)


2.

데이터 타입 


List, Tuple, Complex number


Dictionary -> key & value


set 집합


File Object



"마크 3개 -> 줄바꿈에서


'''haha''' or """haha"""


**(별2개) == power(제곱)


x[-2] = 오른쪽에서 부터 순서(뒤에서)


tuple -> ( )  ex) (1,2,3,4)  (1, )



#dictionary  x={}  x={1:"one", 2:"two"}


#set 중복 안됨 x = set ([1,2,2,3,3,...])  -> 1,2,3,...


메소드 & 함수의 차이 ==> class에 연계되어 있는 함수가 메소드임


for size in range (5, 60, 2);



3.


List


Array 흡사, data type 달라도 ok!, mutable(변경가능) <--> immutable (ex) tuple



연산:  // -> 소수점 없앤 나머지,  / -> 소수점 나오는 나머지



sort(), reverse(), pop()...

String str(), repr(), split, replace




4.

크롤링

import urllib.request

import urllib.parse

import re?


url = 'xxx.org'

values = {'s': 'python', 'submit': 'search'}

data = urllib.parse.urlencode(values)

data = data.encode('utf-8')


req = urllib.request.Request(url, data)

resp = urllib.request.urlopen(req)

respData = resp.read()


print(respData)




5.

sqlite3


import sqlite3


conn = sqlite3.connect('pydbtest.db')

c = conn.cursor()

c.execute ('create table (id integer, ...)')

...execute ('insert int')

result = c.execute ('select * from ...')


for row in result:

print(row[0], row[1])






'파이썬' 카테고리의 다른 글

Flask - Overview  (0) 2022.03.16
selenium 모듈 사용  (0) 2020.04.13
파이썬 크롤링  (0) 2020.01.24

+ Recent posts