Skip to content

c12k/FlaskAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlaskAPI

API Training example

Context for this example

Assumptions

  • Basic Python understanding
  • Basic Flask understanding
  • Basic HTTP and REST endpoints (GET, POST ...)
  • Flask Restful for the API library

setup

run examples

example 1 - simple API creation and call

  • in a terminal run python test1.py
  • in a browser go to localhost click the call api button (it fails)
  • in another terminal run python app1.py
  • in a browser go to localhost:5000 check that api is healthy
  • in a browser go to localhost click the call api button (it returns api response)

example 2 - extend example 1 with argument passing

  • in another terminal run python test2.py
  • in a browser go to localhost click the call api button
  • in a terminal run python app2.py
  • in a browser go to localhost:5000 check that api is healthy

example 3 - google cloud function as an api

  • setup:
    • get a google cloud trial account
    • go to default project
    • enable billing
    • enable cloud functions api
  • go to cloud functions
  • modify the default python function
    • select python 3.7 as the runtime
    • modify the function to do something useful
    • click create
  • test it in a browser or postman
  • copy the url to test3.py code
  • in a terminal run python test3.py
  • cleanup: delete your function to avoid ongoing costs

further reading

About

API Training example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published