DEV Community

loading...
Cover image for Decorators - Building an API in Python with Flask
Microsoft Azure

Decorators - Building an API in Python with Flask

Brian Clark ๐Ÿ’ก
Smooth Jazz
Originally published at clarkio.com ใƒป3 min read

In this session, Brian and chat learn about decorators with Flask as they build out an API in Python. They started off by getting stuck on an issue with recreating the same environment from past sessions but work through it and fix the install script. They finish up by successfully implementing a decorator that checks if the request to the API has been authenticated.

The following are notes and details recapping a past live stream where we live code together. The idea behind these streams is that they provide real-world examples of running into problems and solving them or working towards solving them live. Enjoy this latest one on Python ๐Ÿ™‚๐Ÿ‘

Wednesday - January 29, 2019

Goals

  • โœ” Warm up/Catch up with chat
  • โœ” Learn about Decorators in Python
  • โœ” Closing and raid @GarethHubball

Results

  • Fixed an issue with the environment installation script to make sure our project can be setup and run easily
  • Learned about decorators
  • Learned about the build in Session class available in Flask
  • Created our own decorator to protect an API endpoint

Resources

VS Code Extensions Shown/Used

Clips

Clips are a feature on Twitch that let you cut and capture segments of the live stream in the moment (up to 60 seconds). See how to use clips on Twitch for more details. The following are some fun moments captured from this stream:

  • N/A

Segments

Links not working on Twitch? It's most likely because Twitch will only save my stream recordings for about 60 days. Use the YouTube link at the top of this page instead.

This table helps point out different segments of the stream (highlighted in bold) or moments we learned something (not bold). The timestamps link to the video on Twitch at that point in the recording. If you'd like the YouTube link above will have similar timestamps and link to those same points in the recording as well.

Timestamp Topic
00:04:15 Stream is back and we're moving into the Python stuffs
00:07:05 Reading/learning about view decorators in Flask
00:08:38 View Decorators (created by @murgmasallam)
00:12:09 Authentication vs. authorization discussion
00:19:50 Environment setup (created by @GarethHubball)
00:40:25 Looking at decorators (created by @GarethHubball)
00:45:31 Debugging the container (created by @GarethHubball)
01:37:23 Finish fixing the environment and now moving on to the login decorator again
03:23:28 Checking in changes by forking repo (created by @codesillystuff)
03:28:45 Closing and raid

YouTube Video

Get connected with Cecil Phillip

Get connected with Brian Clark


Thanks for reading this article. If you're interested in finding more content from Microsoft Cloud Advocates check out this monthly curated newsletter: Developer Community Newsletter

Discussion (0)