SlideShare a Scribd company logo
Entrepreneurship open school
Programming Course
-Flask and Heroku in Python-
Thursday, May 18, 2017
Tokyo, Japan
Naoki Watanabe
Thursday, May 18. 2017 Programming course 1
Goal of courses: Run Lean and create app
• Search what people what
• Lauch MVP (Minimum Viable Product)
Thursday, May 18. 2017 Programming course 2
Goals of today’s lecture
• Install Python with conda
• Create simple web application with Flask
• Publish your application freely on Heroku via Git
Thursday, May 18. 2017 Programming course 3
Contents
• Install Anaconda powered by Python
• Learn basic Python grammar
• Follow Flask, web framework, tutorial
• Create your web application powered by Flask
• Public your application
Thursday, May 18. 2017 Programming course 4
What is Python and why?
• It’s a programming language.
• Very simple and nice to learn for beginner
• Many company use it (Google’s Gmail, Map, Earth, YouTube).
• It goes with data science, machine learning and deep learning
Thursday, May 18. 2017 Programming course 5
Install Python via Conda
• Conda is package controller
• Anaconda is conda and some packages.
• Search “Anaconda install” on Google.
• It is tough to go with python on Windows, and windows user
has to install anaconda, not from python official page.
• There is also miniconda, smaller alternative to anaconda.
Thursday, May 18. 2017 Programming course 6
Thursday, May 18. 2017 Programming course 7
Create a virtual environment
$ conda -V
$ conda create –n venv
$ source activate venv
(venv) $
To deactivate, $ source deactivate
-n: specifies the name of a virtual environment
To activate/deactivate on Windows, remove source.
$ activate venv
Thursday, May 18. 2017 Programming course 8
For beginner, keep three things in mind
• Codes goes from up to down.
• You can switch code by if else clause.
• You can iterate by for loop.
You will see how to in the next slides.
Thursday, May 18. 2017 Programming course 9
sample.py – print(1) – 1.1
Make a file sample.py that contains only
print(1)
Thursday, May 18. 2017 Programming course 10
sample.py – print(1) 1.2
Run Terminal (Mac or Linux) or Command Prompt (Windows)
$ cd path/to/folder/where/sample.py/is
$ python sample.py
Then, is 1 printed? Your first python code ran perfectly !
Thursday, May 18. 2017 Programming course 11
sample.py 2 – string is what quoted -
Thursday, May 18. 2017 Programming course 12
sample.py 3 – list -
Thursday, May 18. 2017 Programming course 13
sample.py 4 – loop -
Thursday, May 18. 2017 Programming course 14
sample.py 5 – if else clause -
Thursday, May 18. 2017 Programming course 15
sample.6 - function
Thursday, May 18. 2017 Programming course 16
Q. Fizz Buzz
• Count a number from 1 to 100, but any number divisible by
three is replaced by the word fizz and any divisible by five by
the word buzz. Numbers divisible by both become fizz buzz
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz
Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28,
29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ...
To get reminar, use %. Ex. 5%2. To diverge into three or more,
use if…elif…else.
Thursday, May 18. 2017 Programming course 17
A. FizzBuzz
Thursday, May 18. 2017 Programming course 18
A2. FizzBuzz (one line)
Thursday, May 18. 2017 Programming course 19
Create simple web app with flask
• Flask is a framework to make a website easily.
• You can make a web app just in five lines.
• Pinterest, LinkedIn, and Flask community page use it.
• The most popular Python web framework on GitHub
(mid2016)
• The next slides follows tutorial
http://flask.pocoo.org/docs/0.12/quickstart/
Thursday, May 18. 2017 Programming course 20
hello.py #1 Go to http://localhost:5000
Thursday, May 18. 2017 Programming course 21
hello.py #2 http://localhost:5000/hello
Thursday, May 18. 2017 Programming course 22
hello.py #3 http://localhost:5000/user/bob
Also go to http://localhost:5000/post/999
Thursday, May 18. 2017 Programming course 23
hello.py #4.1 Render html
Thursday, May 18. 2017 Programming course 24
hello.py #4.2 make templates/hello.html
/hello.py
/templates
/hello.html
Thursday, May 18. 2017 Programming course 25
hello.html #4.3 edit hello.html
Thursday, May 18. 2017 Programming course 26
Hypothesis #5.0
• Some people love cat and want to see as many cat gifs.
• You are going to create MVP.
• Application just shows cat gif.
Thursday, May 18. 2017 Programming course 27
cat.py #5.1 Create your own app!
/cat.py
/templates
/cat.html
Thursday, May 18. 2017 Programming course 28
cat.py #5.2
Thursday, May 18. 2017 Programming course 29
We use cat API #5.3
• Application Program
Interface (API) is set of tools
for applications.
• Many service provide API.
• You can use Google Map API,
YouTube API, Amazon API
and many others to create
your web service.
Thursday, May 18. 2017 Programming course 30
cat.html #5.4
Thursday, May 18. 2017 Programming course 31
#5.6 Run application
• It shows a cat gif randomly.
Thursday, May 18. 2017 Programming course 32
cat.py #5.7 Show nice nine gif animations
Thursday, May 18. 2017 Programming course 33
cat.html #5.8 Show nice nine gif anis
Thursday, May 18. 2017 Programming course 34
#5.9 http://localhost:5000
Thursday, May 18. 2017 Programming course 35
cat.py #5.11 powered by Bootstrap
Thursday, May 18. 2017 Programming course 36
Get Bootstrap link #5.12
• Search “Bootstrap getting started” on Google
Thursday, May 18. 2017 Programming course 37
cat.html #5.13 powered by Bootstrap
Thursday, May 18. 2017 Programming course 38
#5.14 Run app
Thursday, May 18. 2017 Programming course 39
#5.15 See it’s responding
Thursday, May 18. 2017 Programming course 40
What is Heroku? #1
• You can publish your app on Heroku
• Heroku is free to use (They also have a paid plan.)
• Before start, remove debug=True in cat.py
Thursday, May 18. 2017 Programming course 41
Create Heroku account and install #2
• Search “Heroku” on Google
• Create an account (choose Python)
• Install heroku CLI (This may take a while)
• For Mac, brew install heroku
• For Windows, search “Heroku CLI windows”. Download and install it.
• Close and start terminal (command prompt on Win) again
Thursday, May 18. 2017 Programming course 42
Create a runtime.txt #3
$ echo python-3.6.1 > runtime.txt
Let runtime.txt contain only above one line.
https://devcenter.heroku.com/articles/python-runtimes
/runtime.txt
/requirements.txt
/cat.py
/templates
/cat.html
Thursday, May 18. 2017 Programming course 43
Create a requirements.txt #4.1
$ pip freeze > requirements.txt
, but change into conda==4.3.16 as Heroku does’nt newer.
Make requirements.txt contain just above two lines.
/cat.py
/requirements.txt
/templates
/cat.html
Thursday, May 18. 2017 Programming course 44
My requirements.txt #4.2
beautifulsoup4==4.6.0
conda==4.3.16
Flask==0.12.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
requests==2.12.4
Werkzeug==0.12.2
Thursday, May 18. 2017 Programming course 45
Create a Procfile # 5
$ echo web: gunicorn cat:app --log-file=- > Procfile
Thursday, May 18. 2017 Programming course 46
Login to Heroku and create app #6.1
$ heroku
$ heroku create
You can access URL shown
Thursday, May 18. 2017 Programming course 47
Push app on Heroku #6.2
$ git init
$ git add .
$ git status
$ git commit –m “Initialize repository”
$ git log
$ git push heroku master
Thursday, May 18. 2017 Programming course 48
Upload to Heroku #6.3
$ git push heroku master
$ heroku ps:scale web=1
$ heroku ps
$ heroku open
Thursday, May 18. 2017 Programming course 49
See your app #7
Thursday, May 18. 2017 Programming course 50
Create a repo on GitHub #8.1 if you want
Thursday, May 18. 2017 Programming course 51
Push to your GitHub Repository
Copy Git URL for “git remote add origin <URL>”
$ git remote add origin
https://github.com/<username>/<repository_name>.git
$ git push origin master
Thursday, May 18. 2017 Programming course 52
GitHub Repository #8
Thursday, May 18. 2017 Programming course 53
Bibliography
• https://immense-escarpment-11300.herokuapp.com/
• http://qiita.com/kounoike/items/6fc31fe051e5d688f136
• http://flask.pocoo.org/docs/latest/quickstart/
• https://devcenter.heroku.com/articles/getting-started-with-
python
• http://michaeljgilliland.blogspot.jp/2013/01/one-line-fizz-
buzz-test-in-python.html
Thursday, May 18. 2017 Programming course 54
That’s all. Thank you, folks.
Thursday, May 18. 2017 Programming course 55

More Related Content

What's hot

Web components training setup knowledge
Web components training setup knowledgeWeb components training setup knowledge
Web components training setup knowledge
btopro
 
Build a Web App with JavaScript & jQuery
Build a Web App with JavaScript & jQueryBuild a Web App with JavaScript & jQuery
Build a Web App with JavaScript & jQuery
Thinkful
 
Standardizing WordPress Workflow
Standardizing WordPress WorkflowStandardizing WordPress Workflow
Standardizing WordPress Workflow
Digital Strategy Works LLC
 
Deck 6-130-441
Deck 6-130-441Deck 6-130-441
Deck 6-130-441
Justin Ezor
 
MMVC2015 - Teaching writing using voice tools on mobile devices and iPads
MMVC2015 - Teaching writing using voice tools on mobile devices and iPadsMMVC2015 - Teaching writing using voice tools on mobile devices and iPads
MMVC2015 - Teaching writing using voice tools on mobile devices and iPads
Vance Stevens
 
Introduction about wireframing and responsive webdesign
Introduction about wireframing and responsive webdesignIntroduction about wireframing and responsive webdesign
Introduction about wireframing and responsive webdesign
ipmindthegap
 
The Child Theme Dilemma (EN) - Milano Edition
The Child Theme Dilemma (EN) - Milano EditionThe Child Theme Dilemma (EN) - Milano Edition
The Child Theme Dilemma (EN) - Milano Edition
Torsten Landsiedel
 
website la 11/28
website la 11/28website la 11/28
website la 11/28
Thinkful
 
Modern Messaging for Distributed Systems
Modern Messaging for Distributed SystemsModern Messaging for Distributed Systems
Modern Messaging for Distributed Systems
Andrea Rabbaglietti
 
Bwhtmlpdx0809
Bwhtmlpdx0809Bwhtmlpdx0809
Bwhtmlpdx0809
Thinkful
 

What's hot (10)

Web components training setup knowledge
Web components training setup knowledgeWeb components training setup knowledge
Web components training setup knowledge
 
Build a Web App with JavaScript & jQuery
Build a Web App with JavaScript & jQueryBuild a Web App with JavaScript & jQuery
Build a Web App with JavaScript & jQuery
 
Standardizing WordPress Workflow
Standardizing WordPress WorkflowStandardizing WordPress Workflow
Standardizing WordPress Workflow
 
Deck 6-130-441
Deck 6-130-441Deck 6-130-441
Deck 6-130-441
 
MMVC2015 - Teaching writing using voice tools on mobile devices and iPads
MMVC2015 - Teaching writing using voice tools on mobile devices and iPadsMMVC2015 - Teaching writing using voice tools on mobile devices and iPads
MMVC2015 - Teaching writing using voice tools on mobile devices and iPads
 
Introduction about wireframing and responsive webdesign
Introduction about wireframing and responsive webdesignIntroduction about wireframing and responsive webdesign
Introduction about wireframing and responsive webdesign
 
The Child Theme Dilemma (EN) - Milano Edition
The Child Theme Dilemma (EN) - Milano EditionThe Child Theme Dilemma (EN) - Milano Edition
The Child Theme Dilemma (EN) - Milano Edition
 
website la 11/28
website la 11/28website la 11/28
website la 11/28
 
Modern Messaging for Distributed Systems
Modern Messaging for Distributed SystemsModern Messaging for Distributed Systems
Modern Messaging for Distributed Systems
 
Bwhtmlpdx0809
Bwhtmlpdx0809Bwhtmlpdx0809
Bwhtmlpdx0809
 

Similar to Programming Lecture 2nd - Flask and Heroku in Python -

Start Flying with Python & Apache TinkerPop
Start Flying with Python & Apache TinkerPopStart Flying with Python & Apache TinkerPop
Start Flying with Python & Apache TinkerPop
Jason Plurad
 
Untangling4
Untangling4Untangling4
Untangling4
Derek Jacoby
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matter
Mizno Kruge
 
Pycon2017 instagram keynote
Pycon2017 instagram keynotePycon2017 instagram keynote
Pycon2017 instagram keynote
Lisa Guo
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
Aaron Lamphere
 
Python webinar 2nd july
Python webinar 2nd julyPython webinar 2nd july
Python webinar 2nd july
Vineet Chaturvedi
 
TypeScript 101 - We RISE Tech Conference
TypeScript 101 - We RISE Tech ConferenceTypeScript 101 - We RISE Tech Conference
TypeScript 101 - We RISE Tech Conference
Frances Coronel
 
Everything you wanted to know about making an R package but were afraid to ask
Everything you wanted to know about making an R package but were afraid to askEverything you wanted to know about making an R package but were afraid to ask
Everything you wanted to know about making an R package but were afraid to ask
Emily Robinson
 
Lecture for Bootstrap and flask in Python
Lecture for Bootstrap and flask in PythonLecture for Bootstrap and flask in Python
Lecture for Bootstrap and flask in Python
Naoki Watanabe
 
Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"
Sigma Software
 
Hands on iOS developments with Jenkins
Hands on iOS developments with JenkinsHands on iOS developments with Jenkins
Hands on iOS developments with Jenkins
eXo Platform
 
Hello World! with Python
Hello World! with PythonHello World! with Python
Hello World! with Python
Dhanashree Prasad
 
Wordcamp Kanpur 2017
Wordcamp Kanpur 2017Wordcamp Kanpur 2017
Wordcamp Kanpur 2017
Marius Cristea
 
SharePoint Framework tips and tricks
SharePoint Framework tips and tricksSharePoint Framework tips and tricks
SharePoint Framework tips and tricks
Giuseppe Marchi
 
April JavaScript Tools
April JavaScript ToolsApril JavaScript Tools
April JavaScript Tools
wolframkriesing
 
Enterprise PHP (Zend UK Business Conference)
Enterprise PHP (Zend UK Business Conference)Enterprise PHP (Zend UK Business Conference)
Enterprise PHP (Zend UK Business Conference)
Ivo Jansch
 
Google Cloud: Next'19 Extended Hanoi
Google Cloud: Next'19 Extended HanoiGoogle Cloud: Next'19 Extended Hanoi
Google Cloud: Next'19 Extended Hanoi
GCPUserGroupVietnam
 
Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.js
Sebastian Springer
 
Clojure.tokyo.descjop
Clojure.tokyo.descjopClojure.tokyo.descjop
Clojure.tokyo.descjop
Kazuhiro Hara
 
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdfLearn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
NemoPalleschi
 

Similar to Programming Lecture 2nd - Flask and Heroku in Python - (20)

Start Flying with Python & Apache TinkerPop
Start Flying with Python & Apache TinkerPopStart Flying with Python & Apache TinkerPop
Start Flying with Python & Apache TinkerPop
 
Untangling4
Untangling4Untangling4
Untangling4
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matter
 
Pycon2017 instagram keynote
Pycon2017 instagram keynotePycon2017 instagram keynote
Pycon2017 instagram keynote
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Python webinar 2nd july
Python webinar 2nd julyPython webinar 2nd july
Python webinar 2nd july
 
TypeScript 101 - We RISE Tech Conference
TypeScript 101 - We RISE Tech ConferenceTypeScript 101 - We RISE Tech Conference
TypeScript 101 - We RISE Tech Conference
 
Everything you wanted to know about making an R package but were afraid to ask
Everything you wanted to know about making an R package but were afraid to askEverything you wanted to know about making an R package but were afraid to ask
Everything you wanted to know about making an R package but were afraid to ask
 
Lecture for Bootstrap and flask in Python
Lecture for Bootstrap and flask in PythonLecture for Bootstrap and flask in Python
Lecture for Bootstrap and flask in Python
 
Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"
 
Hands on iOS developments with Jenkins
Hands on iOS developments with JenkinsHands on iOS developments with Jenkins
Hands on iOS developments with Jenkins
 
Hello World! with Python
Hello World! with PythonHello World! with Python
Hello World! with Python
 
Wordcamp Kanpur 2017
Wordcamp Kanpur 2017Wordcamp Kanpur 2017
Wordcamp Kanpur 2017
 
SharePoint Framework tips and tricks
SharePoint Framework tips and tricksSharePoint Framework tips and tricks
SharePoint Framework tips and tricks
 
April JavaScript Tools
April JavaScript ToolsApril JavaScript Tools
April JavaScript Tools
 
Enterprise PHP (Zend UK Business Conference)
Enterprise PHP (Zend UK Business Conference)Enterprise PHP (Zend UK Business Conference)
Enterprise PHP (Zend UK Business Conference)
 
Google Cloud: Next'19 Extended Hanoi
Google Cloud: Next'19 Extended HanoiGoogle Cloud: Next'19 Extended Hanoi
Google Cloud: Next'19 Extended Hanoi
 
Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.js
 
Clojure.tokyo.descjop
Clojure.tokyo.descjopClojure.tokyo.descjop
Clojure.tokyo.descjop
 
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdfLearn to Code with MIT App Inventor ( PDFDrive ).pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
 

More from Naoki Watanabe

Deep learning basics described
Deep learning basics describedDeep learning basics described
Deep learning basics described
Naoki Watanabe
 
shuumai deep learning
shuumai deep learning shuumai deep learning
shuumai deep learning
Naoki Watanabe
 
アントレプレナーシップ論講座の卒業生による話(2019/04/20)
アントレプレナーシップ論講座の卒業生による話(2019/04/20)アントレプレナーシップ論講座の卒業生による話(2019/04/20)
アントレプレナーシップ論講座の卒業生による話(2019/04/20)
Naoki Watanabe
 
Basic explanation of Generative adversarial networks on MNIST
Basic explanation of Generative adversarial networks on MNISTBasic explanation of Generative adversarial networks on MNIST
Basic explanation of Generative adversarial networks on MNIST
Naoki Watanabe
 
Create line bot with Google Apps Script
Create line bot with Google Apps ScriptCreate line bot with Google Apps Script
Create line bot with Google Apps Script
Naoki Watanabe
 
LINE bot with Google Apps Script to manage reservation
LINE bot with Google Apps Script to manage reservationLINE bot with Google Apps Script to manage reservation
LINE bot with Google Apps Script to manage reservation
Naoki Watanabe
 
Lecuture on Deep Learning API
Lecuture on Deep Learning APILecuture on Deep Learning API
Lecuture on Deep Learning API
Naoki Watanabe
 
tinder automation
tinder automationtinder automation
tinder automation
Naoki Watanabe
 
Mcluhan’s medium
Mcluhan’s mediumMcluhan’s medium
Mcluhan’s medium
Naoki Watanabe
 
Bitcoin4beginners
Bitcoin4beginnersBitcoin4beginners
Bitcoin4beginners
Naoki Watanabe
 
物理はどこで発見されるか
物理はどこで発見されるか物理はどこで発見されるか
物理はどこで発見されるか
Naoki Watanabe
 
ちょうかんたんワインこうざ
ちょうかんたんワインこうざちょうかんたんワインこうざ
ちょうかんたんワインこうざ
Naoki Watanabe
 

More from Naoki Watanabe (12)

Deep learning basics described
Deep learning basics describedDeep learning basics described
Deep learning basics described
 
shuumai deep learning
shuumai deep learning shuumai deep learning
shuumai deep learning
 
アントレプレナーシップ論講座の卒業生による話(2019/04/20)
アントレプレナーシップ論講座の卒業生による話(2019/04/20)アントレプレナーシップ論講座の卒業生による話(2019/04/20)
アントレプレナーシップ論講座の卒業生による話(2019/04/20)
 
Basic explanation of Generative adversarial networks on MNIST
Basic explanation of Generative adversarial networks on MNISTBasic explanation of Generative adversarial networks on MNIST
Basic explanation of Generative adversarial networks on MNIST
 
Create line bot with Google Apps Script
Create line bot with Google Apps ScriptCreate line bot with Google Apps Script
Create line bot with Google Apps Script
 
LINE bot with Google Apps Script to manage reservation
LINE bot with Google Apps Script to manage reservationLINE bot with Google Apps Script to manage reservation
LINE bot with Google Apps Script to manage reservation
 
Lecuture on Deep Learning API
Lecuture on Deep Learning APILecuture on Deep Learning API
Lecuture on Deep Learning API
 
tinder automation
tinder automationtinder automation
tinder automation
 
Mcluhan’s medium
Mcluhan’s mediumMcluhan’s medium
Mcluhan’s medium
 
Bitcoin4beginners
Bitcoin4beginnersBitcoin4beginners
Bitcoin4beginners
 
物理はどこで発見されるか
物理はどこで発見されるか物理はどこで発見されるか
物理はどこで発見されるか
 
ちょうかんたんワインこうざ
ちょうかんたんワインこうざちょうかんたんワインこうざ
ちょうかんたんワインこうざ
 

Recently uploaded

Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
riddhimaagrawal986
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
TaghreedAltamimi
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 

Recently uploaded (20)

Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 

Programming Lecture 2nd - Flask and Heroku in Python -

  • 1. Entrepreneurship open school Programming Course -Flask and Heroku in Python- Thursday, May 18, 2017 Tokyo, Japan Naoki Watanabe Thursday, May 18. 2017 Programming course 1
  • 2. Goal of courses: Run Lean and create app • Search what people what • Lauch MVP (Minimum Viable Product) Thursday, May 18. 2017 Programming course 2
  • 3. Goals of today’s lecture • Install Python with conda • Create simple web application with Flask • Publish your application freely on Heroku via Git Thursday, May 18. 2017 Programming course 3
  • 4. Contents • Install Anaconda powered by Python • Learn basic Python grammar • Follow Flask, web framework, tutorial • Create your web application powered by Flask • Public your application Thursday, May 18. 2017 Programming course 4
  • 5. What is Python and why? • It’s a programming language. • Very simple and nice to learn for beginner • Many company use it (Google’s Gmail, Map, Earth, YouTube). • It goes with data science, machine learning and deep learning Thursday, May 18. 2017 Programming course 5
  • 6. Install Python via Conda • Conda is package controller • Anaconda is conda and some packages. • Search “Anaconda install” on Google. • It is tough to go with python on Windows, and windows user has to install anaconda, not from python official page. • There is also miniconda, smaller alternative to anaconda. Thursday, May 18. 2017 Programming course 6
  • 7. Thursday, May 18. 2017 Programming course 7
  • 8. Create a virtual environment $ conda -V $ conda create –n venv $ source activate venv (venv) $ To deactivate, $ source deactivate -n: specifies the name of a virtual environment To activate/deactivate on Windows, remove source. $ activate venv Thursday, May 18. 2017 Programming course 8
  • 9. For beginner, keep three things in mind • Codes goes from up to down. • You can switch code by if else clause. • You can iterate by for loop. You will see how to in the next slides. Thursday, May 18. 2017 Programming course 9
  • 10. sample.py – print(1) – 1.1 Make a file sample.py that contains only print(1) Thursday, May 18. 2017 Programming course 10
  • 11. sample.py – print(1) 1.2 Run Terminal (Mac or Linux) or Command Prompt (Windows) $ cd path/to/folder/where/sample.py/is $ python sample.py Then, is 1 printed? Your first python code ran perfectly ! Thursday, May 18. 2017 Programming course 11
  • 12. sample.py 2 – string is what quoted - Thursday, May 18. 2017 Programming course 12
  • 13. sample.py 3 – list - Thursday, May 18. 2017 Programming course 13
  • 14. sample.py 4 – loop - Thursday, May 18. 2017 Programming course 14
  • 15. sample.py 5 – if else clause - Thursday, May 18. 2017 Programming course 15
  • 16. sample.6 - function Thursday, May 18. 2017 Programming course 16
  • 17. Q. Fizz Buzz • Count a number from 1 to 100, but any number divisible by three is replaced by the word fizz and any divisible by five by the word buzz. Numbers divisible by both become fizz buzz 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ... To get reminar, use %. Ex. 5%2. To diverge into three or more, use if…elif…else. Thursday, May 18. 2017 Programming course 17
  • 18. A. FizzBuzz Thursday, May 18. 2017 Programming course 18
  • 19. A2. FizzBuzz (one line) Thursday, May 18. 2017 Programming course 19
  • 20. Create simple web app with flask • Flask is a framework to make a website easily. • You can make a web app just in five lines. • Pinterest, LinkedIn, and Flask community page use it. • The most popular Python web framework on GitHub (mid2016) • The next slides follows tutorial http://flask.pocoo.org/docs/0.12/quickstart/ Thursday, May 18. 2017 Programming course 20
  • 21. hello.py #1 Go to http://localhost:5000 Thursday, May 18. 2017 Programming course 21
  • 22. hello.py #2 http://localhost:5000/hello Thursday, May 18. 2017 Programming course 22
  • 23. hello.py #3 http://localhost:5000/user/bob Also go to http://localhost:5000/post/999 Thursday, May 18. 2017 Programming course 23
  • 24. hello.py #4.1 Render html Thursday, May 18. 2017 Programming course 24
  • 25. hello.py #4.2 make templates/hello.html /hello.py /templates /hello.html Thursday, May 18. 2017 Programming course 25
  • 26. hello.html #4.3 edit hello.html Thursday, May 18. 2017 Programming course 26
  • 27. Hypothesis #5.0 • Some people love cat and want to see as many cat gifs. • You are going to create MVP. • Application just shows cat gif. Thursday, May 18. 2017 Programming course 27
  • 28. cat.py #5.1 Create your own app! /cat.py /templates /cat.html Thursday, May 18. 2017 Programming course 28
  • 29. cat.py #5.2 Thursday, May 18. 2017 Programming course 29
  • 30. We use cat API #5.3 • Application Program Interface (API) is set of tools for applications. • Many service provide API. • You can use Google Map API, YouTube API, Amazon API and many others to create your web service. Thursday, May 18. 2017 Programming course 30
  • 31. cat.html #5.4 Thursday, May 18. 2017 Programming course 31
  • 32. #5.6 Run application • It shows a cat gif randomly. Thursday, May 18. 2017 Programming course 32
  • 33. cat.py #5.7 Show nice nine gif animations Thursday, May 18. 2017 Programming course 33
  • 34. cat.html #5.8 Show nice nine gif anis Thursday, May 18. 2017 Programming course 34
  • 35. #5.9 http://localhost:5000 Thursday, May 18. 2017 Programming course 35
  • 36. cat.py #5.11 powered by Bootstrap Thursday, May 18. 2017 Programming course 36
  • 37. Get Bootstrap link #5.12 • Search “Bootstrap getting started” on Google Thursday, May 18. 2017 Programming course 37
  • 38. cat.html #5.13 powered by Bootstrap Thursday, May 18. 2017 Programming course 38
  • 39. #5.14 Run app Thursday, May 18. 2017 Programming course 39
  • 40. #5.15 See it’s responding Thursday, May 18. 2017 Programming course 40
  • 41. What is Heroku? #1 • You can publish your app on Heroku • Heroku is free to use (They also have a paid plan.) • Before start, remove debug=True in cat.py Thursday, May 18. 2017 Programming course 41
  • 42. Create Heroku account and install #2 • Search “Heroku” on Google • Create an account (choose Python) • Install heroku CLI (This may take a while) • For Mac, brew install heroku • For Windows, search “Heroku CLI windows”. Download and install it. • Close and start terminal (command prompt on Win) again Thursday, May 18. 2017 Programming course 42
  • 43. Create a runtime.txt #3 $ echo python-3.6.1 > runtime.txt Let runtime.txt contain only above one line. https://devcenter.heroku.com/articles/python-runtimes /runtime.txt /requirements.txt /cat.py /templates /cat.html Thursday, May 18. 2017 Programming course 43
  • 44. Create a requirements.txt #4.1 $ pip freeze > requirements.txt , but change into conda==4.3.16 as Heroku does’nt newer. Make requirements.txt contain just above two lines. /cat.py /requirements.txt /templates /cat.html Thursday, May 18. 2017 Programming course 44
  • 46. Create a Procfile # 5 $ echo web: gunicorn cat:app --log-file=- > Procfile Thursday, May 18. 2017 Programming course 46
  • 47. Login to Heroku and create app #6.1 $ heroku $ heroku create You can access URL shown Thursday, May 18. 2017 Programming course 47
  • 48. Push app on Heroku #6.2 $ git init $ git add . $ git status $ git commit –m “Initialize repository” $ git log $ git push heroku master Thursday, May 18. 2017 Programming course 48
  • 49. Upload to Heroku #6.3 $ git push heroku master $ heroku ps:scale web=1 $ heroku ps $ heroku open Thursday, May 18. 2017 Programming course 49
  • 50. See your app #7 Thursday, May 18. 2017 Programming course 50
  • 51. Create a repo on GitHub #8.1 if you want Thursday, May 18. 2017 Programming course 51
  • 52. Push to your GitHub Repository Copy Git URL for “git remote add origin <URL>” $ git remote add origin https://github.com/<username>/<repository_name>.git $ git push origin master Thursday, May 18. 2017 Programming course 52
  • 53. GitHub Repository #8 Thursday, May 18. 2017 Programming course 53
  • 54. Bibliography • https://immense-escarpment-11300.herokuapp.com/ • http://qiita.com/kounoike/items/6fc31fe051e5d688f136 • http://flask.pocoo.org/docs/latest/quickstart/ • https://devcenter.heroku.com/articles/getting-started-with- python • http://michaeljgilliland.blogspot.jp/2013/01/one-line-fizz- buzz-test-in-python.html Thursday, May 18. 2017 Programming course 54
  • 55. That’s all. Thank you, folks. Thursday, May 18. 2017 Programming course 55