Create A REST API with Python Flask and Flask-RestX -Project Tutorial

preview_player
Показать описание
Flask Restx is a Flask extension that helps you build REST APIs with Flask so fast. In this video, we go into building a simple REST API that serves the book data. I walk you through how to use Flask Restx from setting up a virtual environment to implementing Swagger U to document the API.

This video is made for both beginners and advanced Python programmers who want to build REST APIs with Flask, Flask-Restx and Python.

Chapters
0:00 - Inntroduction and Set up
3:05 - Start the server
9:38 - Creating the database model
19:13 - Creating the SQLite database
21:45 - Exploring Flask-SQLAlchemy
26:04 - Creating the fields for object serialization
27:34 - Get all resources
29:51 - Get a single resource
31:51 - Create a new resource
37:24 - Update a resource
41:18 - Delete a resource
44:26 - Documenting the API
51:42 - Wrapping Up

Please like, share, comment

Рекомендации по теме
Комментарии
Автор

The Swagger error at 49:21 is fixed by using

for example.

@api.expect(recipeModel)
def post(self):
pass

SsaliJonathan
Автор

If you have learned from this video, please like, comment and share

SsaliJonathan
Автор

Great video and I want to thank you for providing the git repository.
It helped me with a project I was not well prepared for.
Thanks

superlegend
Автор

Thanks a lot man. Learned a lot on the documentation. But the audio was hard to understand. Although you've already mentioned in the comments that you're sleepy.

mishkataapon
Автор

Try to create MVC series of videos that is helpful to most of people

ittechzoneai
Автор

Just a question, at time 8:55 what programming do u use to run the API?(i'm quite new in creates API) Nice video, it's helping me a lot to improving my studying. i'm gonna share with my classmate.

PsifonGamer
Автор

very good explanation and voice is very low, cannot hear you properly but please fix the swagger issue and I am going to subscribe your channel

ittechzoneai
Автор

I started to doing my project using restful, but as swagger was needed, i had to switch over to restx. What i have notice is that people in restx prefer to use api.route over api.add_resources to add a CRUD method. As i said previously, i started using api.add_resouces, therefore, my class of resources are in different files. But to use swagger, i have to import the object api over to another file. But i simplely can't do it. Could you help?

akemap
Автор

Try it something like below.. @api.doc is for query parameters, wont work for payload.
There's another thing I think instead of using request.get_json(), api.payload is used. Let me know if you have any idea about that :)

@api.expect(book_model)
@api.marshal_with(book_model)
def post(self):
''' Create a new book '''
data=request.get_json()

title=data.get('title')
author=data.get('author')

new_book=Book(title=title, author=author)

db.session.add(new_book)

db.session.commit()

return new_book #{'result' : 'Book Added'}, 201

gauravk
welcome to shbcf.ru