M
M
Mikkkch2020-10-26 11:55:35
Flask
Mikkkch, 2020-10-26 11:55:35

Choosing between Flask and DRF when building a JSON API?

Hello, the task is that it is necessary to create a bulletin board system in the JSON API format.

Some points to clarify what this API will be.
And one more small moment: the front-end will be attached to this project.

  1. The user visits the main page where he is greeted with information about the project, etc. Among other things, a wonderful getting started button will be displayed there, when clicked, it will be transferred to the registration page. By registering, he will be able to log in and get his own key, thanks to which it will be possible to make requests to individual pieces of the API.
  2. On the top of the page there will also be navigation elements such as: contacts, list of apish, etc. When visiting the APIs page, the user will see a wonderful sidebar that will list all the provided API pieces. By selecting what the user wants, a page will be displayed in front of him with a supported request method, an address, and the necessary values. Having entered the values, he, being authorized, will be able to click on the execute button and in front of him in several blocks the results will be displayed in the form of headers and the request body.


In such details, I describe everything to you for a reason, you need to navigate the choice of frame, based on the possibilities and limitations.
If anything, here is our source of inspiration: https://developer.riotgames.com/

Here are the points that made me ask for help here:
  1. DRF is a good framework that provides a lot of things out of the box: authorization by token, sessions, rate limiting. However, it severely limits functionality to the abstraction provided. If I start writing in my own way, and it definitely will, due to the fact that the pages will have a specific look and will need to adapt to it, it will give the impression that I am a cyclist. In addition to that, you will have to climb inside and change the templates to your own, because drfs return their prepared templates by default.
  2. Flask is a framework that allows you to write your own way. In this regard, it is much more convenient, but again, you will have to catch up in the project with what DRF already has or connect third-party libraries.


Note: React will most likely be paired with the selected framework, which will allow, when making a request, without refreshing the page, display headers and body in blocks (I hope)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-10-26
@Mikkkch

And what knowledge in these frameworks? If I had to choose Flask or DRF for API, then definitely DRF. But in order to write in DRF, you need to know Django well and, on the plus side, spend a lot of time learning DRF itself.
And if the condition is something else, but not Django, then I would rather take FastAPI than Flask.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question