Today I will want to present how to create REST API from scratch using python Flask framework. After this tutorial you will be able to start code your own REST API. This is very powerful method to provide interface to Everything ! All you need is to implement functionality for HTTP methods GET, POST, PUT, DELETE and provide user friendly API to allow him interact. You can control network devices, robots, IoT devices etc. In part 1 we will be focus on creating basic REST API service that will store data in memory, next part will include how to use mongoDB database to store data permanently and we will provide authentication for service and extend API.
In part 3 I presented what class is and how we can use it in python. Now I would like to take you to the journey of aggregation behavior of class design. I will create a router and assemble it with interfaces. I also would like to show you objects in memory. After we will finish our little project, you should gain knowledge about object aggregation. Later in next part we will extend code and provide simulated connections between routers. However first we need to bring frankenstein alive:). This part require from you at least knowledge from part 1,2,3. Lets start !
Even if we can build complex data structures using dictionaries or lists, applications rarely base only on build-in data structures. If you plan to create blog, web application or GUI application, network application, you need to have control, think about application users and potential developers. You should create as much as possible reausable code and build libraries. To make this happen, you need to understand what Object Oriented Programming is and what class is.
I selected python, because it has very good support to work with REST APIs, it allows to see your code results faster and it is language that you can use to cover automation tasks in networks, build web applications and really list is almost endless. Its also good language to learn first. Starting from C or C++ could demotivate beginners, instead motivate, and this languages has different use cases, and using them for automation or REST will be painful.