Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Intro to Flask and AT API's
Search
Ian Juma
October 15, 2016
Programming
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Intro to Flask and AT API's
Flask introduction; AfricasTalking API's introduction
Ian Juma
October 15, 2016
Transcript
15 slides
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()
More Decks by Ian Juma
See All by Ian Juma
Scaling notifications; notification-service V2
ianjuma
0
41
Building Infrastructure for the Next Generation of Successful African Ventures - Africa's Talking
ianjuma
0
110
Change Management: Building a CI/CD Pipeline
ianjuma
0
140
Ian J, Salama A.B
ianjuma
0
120
Innovation
ianjuma
0
150
Asynchronous Python with gevent and asyncIO
ianjuma
1
2.6k
Scaling AfricasTalking - DevCraft nairobi
ianjuma
0
280
Other Decks in Programming
See All in Programming
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
310
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
230
RaspberryPi 5で軽くはじめるk3sとtailscaleを用いたホームサーバー構築 (1)
nasum
0
450
読みやすい!と評判(?)の発表の準備にかける私のこだわり
shoheimitani
0
170
眠らない開発チームの作り方
biwakonbu
0
160
Debian JP Projectのサーバー構成
uwabami
1
190
AI Augmentation Techniques with Liberty
ivargrimstad
1
580
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
780
The Cost of the DOM
ypresto
2
820
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
200
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1.1k
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
120
Featured
See All Featured
Navigating Team Friction
lara
192
16k
Heart Work Chapter 1 - Part 1
lfama
PRO
11
37k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.7k
The Invisible Side of Design
smashingmag
301
52k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
690
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
480
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.8k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
640
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
310