Presentation is loading. Please wait.

Presentation is loading. Please wait.

Upnl 24th workshop kim jae chan

Similar presentations


Presentation on theme: "Upnl 24th workshop kim jae chan"— Presentation transcript:

1 Upnl 24th workshop kim jae chan
Introduction to Flask Upnl 24th workshop kim jae chan

2 Flask

3 Python

4 Python werkzeug based

5 Python werkzeug based microframework

6 Python werkzeug based microframework

7 Python?

8

9 Guido van Rossum

10 Guido van Rossum

11 Guido van Rossum Google

12 Guido van Rossum Google 2013- Dropbox

13 Guido van Rossum Script

14 Guido van Rossum Script Easy

15 Guido van Rossum Script Easy Popular

16 def factorial(x): return x <= 0 and 1 or factorial(x-1) * x if __name__ == '__main__': print factorial(100)

17 def factorial(x): return x <= 0 and 1 or factorial(x-1) * x if __name__ == '__main__': print factorial(100) def factorial(x): return reduce(lambda x, y: x * y, range(1, x+1)) if __name__ == '__main__': print factorial(100)

18 def factorial(x): return x <= 0 and 1 or factorial(x-1) * x if __name__ == '__main__': print factorial(100) def factorial(x): return reduce(lambda x, y: x * y, range(1, x+1)) if __name__ == '__main__': print factorial(100) def factorial(x): result = 1 for i in range(1, x+1): result *= i return result if __name__ == '__main__': print factorial(100)

19 Python werkzeug based microframework

20 Werkzeug 벡ㅋ차이크 비슷하게 발음. 독일어로 ‘도구'라는 뜻

21 One of WSGI implementation

22 WSGI?

23 Web Server Gateway Interface

24 Web Server Python Application Python Framework

25 Web Server Python Application Python Framework Request

26 Web Server Python Application Python Framework Request Response

27 WSGI Request Python Application Web Server Python Framework Response
WSGI는 약속. 이걸 구현한 것 중 하나가 werkzeug Response

28 Python werkzeug based microframework

29 Microframework

30 Micro + framework

31 Micro

32 django pip install django
django-admin.py startproject <project_name> cd <project_name> coding.. python manage.py runserver

33 django ASP.NET Create project in Visual Studio.
pip install django django-admin.py startproject <project_name> cd <project_name> coding.. python manage.py runserver ASP.NET Create project in Visual Studio. Many, many files are automatically created. But almost files are useless. coding.. Press F5 to debug

34 Flask pip install flask Open vim coding.. ??? PROFIT!

35 micro != lack of feature

36 micro != lack of feature start quickly

37 micro != lack of feature start quickly simple to use

38 micro != lack of feature start quickly simple to use structural flexibility

39 micro != lack of feature start quickly simple to use structural flexibility extendable

40 Examples

41 app.py from flask import Flask app = Flask(__name__) @app.route('/')
def index(): return u‘Hello, World!' if __name__ == '__main__': app.run(debug=True)

42

43

44 app.py from flask import Flask app = Flask(__name__) @app.route('/')
def index(): return u'Hello, World!‘ @app.route('/<name>') def index_name(name): return u'Hello, ' + name if __name__ == '__main__': app.run(debug=True)

45

46 app.py from flask import Flask app = Flask(__name__) @app.route('/')
def index(): return u'Hello, World!‘ @app.route('/<name>') @app.route('/<name>/<int:times>') def index_name(name, times=None): if not times: times = 1 return (u'Hello, ' + name + '! ') * times if __name__ == '__main__': app.run(debug=True)

47

48 I want to create HTML page!

49 templates/index.html <!doctype html> <html> <head>
<meta charset="utf-8" /> <title>TestPage</title> </head> <body> <h1>{{ content }}<h1> </body> </html>

50 templates/index.html app.py <!doctype html> <html>
<head> <meta charset="utf-8" /> <title>TestPage</title> </head> <body> <h1>{{ content }}<h1> </body> </html> app.py from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): return render_template('index.html', content=u'Hello, World!') @app.route('/<name>') @app.route('/<name>/<int:times>') def index_name(name, times=None): if not times: times = 1 content = (u'Hello, ' + name + '! ') * times return render_template('index.html', content=content) if __name__ == '__main__': app.run(debug=True)

51

52

53 Conclusion

54 Web development is easy to start

55 Web development is easy to start
Flask is useful tool

56 Web development is easy to start
Flask is useful tool Python is also good tool

57 Web development is easy to start
Flask is useful tool Python is also good tool Don’t be afraid of web

58 Most important thing is

59 Most important thing is
Your idea.

60 Reference http://python.org http://flask.pocoo.org

61 The End 고기가 먹고 싶어요


Download ppt "Upnl 24th workshop kim jae chan"

Similar presentations


Ads by Google