Flask is Microframework
Jinja2 = templating language for Python
Werkzeug = Python WSGI Utility Library
Flask = Jinja2 + Werkzeug
Jinja2
Jinja2 can generate any text-based format(HTML, XML etc)
A template contains variables or expressions, which get replaced with values when the template is evaluated, and tags, which control the logic of the template
users = [
{"url" : "http://daum.net", "username" : "jonghokim"},
{"url" : "http://naver.com", "username" : "moonsookim"}
]
WSGI
Browser: IE, Chrome, Firefox, etc...
Server : Apache, Nginx, etc...
App : Django, Flask, etc...
WSGI는 Server와 App이 통신하는 명세이다.
WerkZeug(2)
WerkZeug : WSGI Library. not FrameWork.
WSGI itself is a protocol or convention that ensures that your web application can speak with the webserver. [PEP333]
[without WerkZeug - start_response in 'python']
[WerkZeug]
Werkzeug(2) - 출처 : http://spoqa.github.io/2012/01/16/wsgi-and-flask.html
environ : Python dictionary - HTTP(RFC2616)요청을 처리하는데 필요한 정보가 들어있다.
Werkzeug의 기능
Werkzeug(3) - Middleware
Middleware에는 어떤 것들이? - WSGI명세에 없지만 필요한 기능들이 들어간다.
Flask = Jinja2 + Werkzeug
app = Flask(__name__) #app을 인스턴스화
@app.route("/") #URL Route - "localhost:5000/"에 접속하면 아래 def 실행
@ -> decorator 파이썬 Syntax중 하나
app.run()으로 실행
Flask Extensions
Flask is microframework.
So, we need Flask-Extensions (http://flask.pocoo.org/extensions/)
Flask project simulation
source - https://github.com/mitsuhiko/flask/tree/master/examples/flaskr