Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Intro to Flask and AT API's
Search
Ian Juma
October 15, 2016
Programming
0
66
Intro to Flask and AT API's
Flask introduction; AfricasTalking API's introduction
Ian Juma
October 15, 2016
Tweet
Share
More Decks by Ian Juma
See All by Ian Juma
Scaling notifications; notification-service V2
ianjuma
0
23
Building Infrastructure for the Next Generation of Successful African Ventures - Africa's Talking
ianjuma
0
74
Change Management: Building a CI/CD Pipeline
ianjuma
0
110
Ian J, Salama A.B
ianjuma
0
78
Innovation
ianjuma
0
120
Asynchronous Python with gevent and asyncIO
ianjuma
1
2.2k
Scaling AfricasTalking - DevCraft nairobi
ianjuma
0
240
Other Decks in Programming
See All in Programming
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
4
390
Domain-Driven Transformation
hschwentner
2
1.5k
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
43
19k
雑に思考を整理する技術と効能
konifar
63
30k
Fast JSX: Don't clone props object #28768
yossydev
1
190
if constexpr文はテンプレート世界のラムダ式である
faithandbrave
3
670
Exploring the Implementation of “t.Run”, “t.Parallel”, and “t.Cleanup”
akarin
1
130
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
140
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
170
TCAとKMPを用いた新規動画配信アプリ 「ABEMA Live」の設計
tomu28
2
130
GitHub Copilotのススメ
marcy731
1
230
Documentation for users with AsciiDoc and Antora
ahus1
0
370
Featured
See All Featured
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
Building an army of robots
kneath
300
41k
Being A Developer After 40
akosma
66
580k
Building Better People: How to give real-time feedback that sticks.
wjessup
356
18k
Scaling GitHub
holman
457
140k
Code Review Best Practice
trishagee
56
15k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Infographics Made Easy
chrislema
238
18k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.6k
Transcript
API’s with Flask Python, Flask, API’s, AT API’s
whoami @IanJuma github.com/ianjuma medium.com/@IanJuma
API
What’s an API A contract between two pieces of software
or services
Setup Python 2.7 / 3. PIP Flask ngrok (local tunneling)
Sample project
Why Flask Simple Un-opinionated Minimal 100% WSGI Lots of extensions
Class based views
Flask API from flask import Flask app = Flask(__name__) @app.route("/api")
def resource(): # perform task return "resource" if __name__ == "__main__": app.run()
API methods from flask import Flask app = Flask(__name__) @app.route("/api”,
methods=[’POST’, ‘GET’, ‘DELETE’, ‘PUT’]) def resource(): # perform task return "resource" if __name__ == "__main__": app.run()
methods... GET - fetch a resource POST - add a
resource DELETE - remove a resource PUT - update a resource HEAD - fetch information about a resource without fetching the resource (options)
Library text API from flask import Flask app = Flask(__name__)
@app.route("/library/api") def resource(): # fetch text from harry potter return harry_potter if __name__ == "__main__": app.run()
Code ... Deep dive
Send SMS from AfricasTalkingGateway import AfricasTalkingGateway # gateway instance gateway
= AfricasTalkingGateway(username, apikey) # send message gateway.sendMessage("+254 703567XXX", "hello...")
Send Airtime from AfricasTalkingGateway import AfricasTalkingGateway # gateway instance gateway
= AfricasTalkingGateway(username, apikey) # send message gateway.sendAirtime("+254 703567XXX", "amount")
Making a voice call gateway = AfricasTalkingGateway(username, apikey) results =
gateway.call(callFrom, callTo)
Handling a call from flask import Flask app = Flask(__name__)
@app.route("/voice/api") def voice(): res = '<Response><Say>"hi, I am testing"</Say></Response>' return res if __name__ == "__main__": app.run()