Тёмный

REST API With Flask & SQL Alchemy 

Traversy Media
Подписаться 2,3 млн
Просмотров 297 тыс.
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 372   
@SimonMarkHolland
@SimonMarkHolland 2 года назад
Another great video thank you. If anyone gets the error "AttributeError: 'list' object has no attribute 'data'", it's because since Marshmallow v3 you don't need the .data attribute as dump returns the data directly ... def get_products(): all_products = Product.query.all() result = products_schema.dump(all_products) return jsonify(result)
@teclote
@teclote 7 месяцев назад
Thank you.
@MoltiSanti
@MoltiSanti Год назад
If when running "db.create_all()" from the Python interpreter you experience "RuntimeError: Working outside of application context.", instead run the following three lines: >>> from app import app, db >>> app.app_context().push() >>> db.create_all()
@tastes-like-straberries
@tastes-like-straberries Год назад
was looking for this. thanks sm
@aditi1786
@aditi1786 Год назад
thanks!!
@davidflaquercc466
@davidflaquercc466 6 месяцев назад
really thanks
@AhmadLiaqat-dj1dm
@AhmadLiaqat-dj1dm 5 месяцев назад
instead you can ad a line of code in you app.py file "# Create all tables within the application context with app.app_context(): db.create_all() "
@johncrunk8038
@johncrunk8038 3 года назад
Thank you for presenting an example by using my favorite two tools - pipenv and vscode. They save so much time and effort. I also ALWAYS create a git repository for projects, even if they are the throwaway kind. As of this date, marshmallow is version 3.0 and the "strict" key is no longer needed or allowed.
@ua83
@ua83 5 лет назад
Thanks for the video Brad. kudos. I was getting this error when sending a GET to return all the Products, To fix it I returned jsonify(result) instead of jsonify(result.data) I hope it will save someone else time =)
@johnnysim1985
@johnnysim1985 5 лет назад
Came here to find this exact problem
@fun2badult
@fun2badult 5 лет назад
this solved my issue too of not finding 'data'
@woltron4o
@woltron4o 5 лет назад
This was my last issue with the code. Thanks.
@parsonsmarcus
@parsonsmarcus 4 года назад
I was just about to comment this myself. Cheers!
@malamhari_
@malamhari_ 4 года назад
You save my time, thanks
@Vt12365
@Vt12365 2 года назад
18:00 - When initialising the schema object, the strict argument is no longer valid, for the newer versions of SQLAlchemy.
@mpilodlamini8407
@mpilodlamini8407 2 года назад
Thank you very much for that. I removed strict=True for now
@askmehow25
@askmehow25 4 года назад
Thank you so much for this. As a part of an interview assignment, I was given a task to create a CRUD system and expose APIs for a table. Starting from absolutely 0 knowledge about Flask, I was able to fully develop it thanks to you. Thank you so much! Do let me know if there is some way I can buy you a couple of beers (your Paypal?)
@Lerklinten
@Lerklinten 3 года назад
Once again a simple and perfect demonstration, love your work! Keep it up
@flat9safety
@flat9safety 5 лет назад
Just a note: jsonify does more than the simple conversion (if I'm not mistaken), it actually does some other prep steps to make it ready to be used as a response. For a simple conversion, you can use the built in module `json` ... json_string = json.dumps(som_python_dict)
@monkeydolla
@monkeydolla 4 года назад
Good Tutorial Thanks Brad Might be something new with Marshmellow but I think that this is the correct synatax - # Init Schema product_schema = ProductSchema() products_schema = ProductSchema(many=True) I tried it with strict and it was dropping an error .. above worked.
@toumalmojumder9487
@toumalmojumder9487 3 года назад
thanks
@NikhilSandella
@NikhilSandella 5 лет назад
Thank you for this video. Please make a video on 'Flask as Rest API and Angular as the Front end.' Thumbs up.
@shameelibrahim7431
@shameelibrahim7431 5 лет назад
Hi Brad, I've been following your channel for the past few months. I have learnt HTML and CSS as well as Python from your channel. I was forced to learn Java in my college as part our curriculum (which I find hard as a first time coder) and currently, we are going to make an Android app Although I find React Native to be really efficient, my professors, insist that I should make an app through Java. Can you include a crash course on Java and Android Studio. sorry if I'm asking too much. Your work is awesome as always
@jwchavez
@jwchavez 5 лет назад
Great video as ever guys. Have a nice and successful 2019 , best wishes from México to both of you!
@MistaT44
@MistaT44 5 лет назад
Excellent video once again Brad!!! I would be grateful if you could do a Flask React app with deployment!
@davidw4918
@davidw4918 4 года назад
Thank you Brad, It is very good tutorial. The sample code works for me.
@leootp22
@leootp22 5 лет назад
Thanks for the awesome vid, really easy to follow and learned so much
@pierre2338
@pierre2338 3 года назад
Really clear tutorial, thank you very much!
@philippegns
@philippegns 3 года назад
Really good video for the basics, thanks !
@kuthub1989
@kuthub1989 5 лет назад
Brad, I'm a big fan of you. please do the full project-based course of a flask in udemy.
@panteliskaramolegkos2693
@panteliskaramolegkos2693 5 лет назад
Very nice tutorial. Would it be possible to elaborate at some point about the necessity of Marshmallow? I didn't quite get why it is being used.
@gianmarcoferrara3397
@gianmarcoferrara3397 5 лет назад
Hi Brad, I would be very happy to have a tutorial about Gatsby + Netlify CMS, I'd be interested to learn the JAM stack.
@alpaslaneldemir6904
@alpaslaneldemir6904 5 лет назад
You might want to check RestPlus.
@baff2129
@baff2129 3 года назад
Very nice tutorial, thanks
@donerlando9949
@donerlando9949 Год назад
At 26:40, would it be all right to replace the two statements: result = products_schema.dump(all_products) return jsonify(result.data) with: products_schema.jsonify(all_products) ? I'm too much of a noob to understand the difference 🙈
@narudh
@narudh 4 года назад
i don't understand why we need to use marshmallow? is it just to serialize the output of sqlalchemy queries and JSONify it?
@AyushGupta-ct2hi
@AyushGupta-ct2hi 2 года назад
Thanks a lot for this, nicly explained but during delete part when I delete any product from the middle let say product number 3 in list of 5 products Is there a way to update its Product id?
@VideoServicesLI
@VideoServicesLI 5 лет назад
Very Interesting - thank you!!
@Fedelios1
@Fedelios1 3 года назад
how can i build the front end now form formularies and everything?
@gleon1602
@gleon1602 3 года назад
I typed in python3 --version into the terminal and it said "Python was not found". How do I resolve this? Edit: Python 3 is already installed on my computer but I still get this message Edit: Nevermind. Everything's working fine.
@HurikaneTv
@HurikaneTv 5 лет назад
Brads channel reminds me everyday that I DON'T KNOW SHIT!
@toekneema
@toekneema 4 года назад
awesome tutorial
@phonzammizaki884
@phonzammizaki884 5 лет назад
Wow that is great. What if I want to make it bigger? Would you make a video tutorial of these Flask Restful and seperate the models, views(with blueprints), and the main app with application factory (create_app() function)? and also add an authentication method. It would be better right?
@thetungnguyen3009
@thetungnguyen3009 5 лет назад
thank you for comment in code
@programinggrid967
@programinggrid967 4 года назад
Please build a chat app using python and flask
@novoehuevoe9340
@novoehuevoe9340 3 года назад
At least you tried
@1cannon3
@1cannon3 5 лет назад
0:27 - Intro to tutorial 1:00 - Intro to the other packages used in this tutorial (SQLAlchemy, Marshmallow, PostMan) 2:01 - Creating virtual environment (Pipenv) 3:09 - Installing dependencies 4:10 - Create main file (app.py) 5:43 - Initialize flask and run server 7:02 - Creating a basic route 7:58 - Making POST request in Postman 8:18 - Setting up database URI 9:04 - Setting up database 10:46 - Initialize database 11:00 - Initialize Marshmallow 11:23 - Creating a class for your resource(s) 16:13 - Creating a product schema (This is where we use Marshmallow) 17:13 - Initialize schema 17:56 - Another schema initialization 18:50 - Creating the database 20:04 - Creating our routes 20:15 - "Create a product" route ('/product') 23:30 - Making a POST request in Postman 24:50 - Creating "fetch all products" route 25:40 - SQLAlchemy .all() method 26:46 - Testing get all products in Postman 27:28 - Creating "get single product" route 29:29 - Creating "update a product" route 31:35 - Making a PUT request to product in Postman 32:21 - Create a delete route 33:49 - Making a DELETE request in Postman
@default_youtube_profile
@default_youtube_profile 5 лет назад
Everything is easy if you put them in a single module, you should organise your app in a proper structure and then explain what you are doing.
@ruudhermans4243
@ruudhermans4243 3 года назад
For people coming across this video in June 2021. I had a few issues using the latest versions of everything. 1. At 18 minutes the schema no longer requires strict = True. 2. At 16.30, result.data should be result.
@baff2129
@baff2129 3 года назад
legend, thanks
@bureaucafeatelier5603
@bureaucafeatelier5603 4 года назад
Quite old, some methods are not the same right now. But it's definitely a good tutorial. The strict param is not accepted right now for marshmallow (product(s)_schema) For the get_all the following lines are the new ones: all_products = Product.query.all() return products_schema.jsonify(all_products)
@suvodeepsinha200
@suvodeepsinha200 3 года назад
Thank you so much, it saved a lot of time Also, could you tell if dump() is depreciated?
@gameofphonesbykv9169
@gameofphonesbykv9169 2 года назад
thanks man
@takich9317
@takich9317 5 лет назад
Hi, am getting an error, (TypeError: __init__() got an unexpected keyword argument 'strict') any advice
@denniskuria5945
@denniskuria5945 5 лет назад
Got same errors too. I removed 'strict' and it worked.
@johnnysim1985
@johnnysim1985 5 лет назад
Also getting this error, anyone know why?
@KushChoudhary
@KushChoudhary 4 года назад
@@johnnysim1985 new version release. Schemas are always strict so no need.
@KushChoudhary
@KushChoudhary 4 года назад
CzemBri ;p
@malamhari_
@malamhari_ 4 года назад
@@KushChoudhary Thanks
@UncleNabs
@UncleNabs 5 лет назад
File "C:\Users\Engr\Documents\flask-api\traversy\app.py", line 47, in add_product name = request.json['name'] TypeError: 'NoneType' object is not subscriptable after I try to make the same post request with postman. And I got the same error with the code from github so I wrote all the code correctly. Can anyone help with this?
@Cocomelonjj22
@Cocomelonjj22 4 года назад
@Isaac Neace SAME PROBLEM
@MaxProgramming
@MaxProgramming 2 года назад
Just for someone who gets stuck when they get all products, the "result" variable will be default be an array/list so you don't need the `data` you can just jsonify(result)
@nickapeed
@nickapeed 3 года назад
For anyone using this now, and update to Marshmallow (from documentation): Setting the strict option on class Meta has no effect on Schema behavior. Passing strict=True or strict=False to the Schema constructor will raise a TypeError.
@azertyuiop7893
@azertyuiop7893 3 года назад
Thanks bro.
@baff2129
@baff2129 3 года назад
legend, thanks
@tastes-like-straberries
@tastes-like-straberries Год назад
yeah i got it and removed it
@hakusho04
@hakusho04 3 года назад
For anyone following this tutorial in 2021 The strict parameter was removed. Schemas are always strict. So product_schema = ProductSchema() products_schema = ProductSchema(many=True)
@adityapanda5311
@adityapanda5311 3 года назад
Thanks
@guenzburghdcl7637
@guenzburghdcl7637 2 года назад
Dont know why Traversy decided to create the database in the terminal makes no sense to me, instead import create_engine from sqlalchemy, then engine=create_engine(use the url Traversy uses) then db.Model.metadata.create_all(engine) and thats it ! You can add ‘if not database_exists(engine.url): db.Model.metadata etc.’ to only create database if it does not exist, that will make your program portable. There are many ways to check if a database exists but installing the sqlalchemy_utils and importing database_exists is easier
@masubaaaron5689
@masubaaaron5689 Год назад
Tell me more about this please, Have you any videos concerning this?
@Ash-em5pm
@Ash-em5pm 5 лет назад
Is this some sort of magic? I swear I was reading flask documentation and now you post a video. Thank you so MUCH BTWBrad, what magic classes do you take,?
@TraversyMedia
@TraversyMedia 5 лет назад
Come on, you know I can't tell you that. Nice try though :)
@wintereh4818
@wintereh4818 5 лет назад
I was just looking into it too! Brad is in tune
@kuthub1989
@kuthub1989 5 лет назад
me too.
@JohnLednicky
@JohnLednicky 2 года назад
Breaking Marshmallow changes since the version used to record this tutorial. 3.0.0b7 (2018-02-03) Features: Backwards-incompatible: Schemas are always strict (#377). The strict parameter is removed. Backwards-incompatible: Schema().load and Schema().dump return data instead of a (data, errors) tuple (#598).
@Cocomelonjj22
@Cocomelonjj22 4 года назад
name=request.json["name"] TypeError: 'NoneType' object is not subscriptable update_product error please help
@julioperezduran4321
@julioperezduran4321 4 года назад
Check headers content-type and set it to json
@julioperezduran4321
@julioperezduran4321 4 года назад
in postman
@reinhard_silaen
@reinhard_silaen 3 года назад
If you found an error about strict or marshmallow. Install the packages following this version: marshmallow==3.0.0b6 marshmallow-sqlalchemy==0.15.0
@imbayi
@imbayi 5 лет назад
This channel is the gift that keeps giving.
@yomajo
@yomajo 4 года назад
Make sure you give back ;)
@brentvsmaximvsone
@brentvsmaximvsone 4 года назад
name = request.json['name'] TypeError: 'NoneType' object is not subscriptable - keep getting this error and looking all over for it, but I have no idea what it means. Can anyone help?
@michael.028
@michael.028 4 года назад
On the get all products route I had to remove .data from result in order to see my products. I was getting the error, " 'list' object has no attribute 'data' ".
@RyuKent
@RyuKent 4 года назад
Use return jsonify(result) instead. You don't need .data
@chinmoyjyotikathar8793
@chinmoyjyotikathar8793 4 года назад
For anyone confused about how the table name is generated, I just realized that on executing the db.create_all() command, a table with same name as the lower cased Class name gets created in SQLite database, so in this case a table named 'product' is created with the defined schema. Also, if Class name has a name like MyProduct then table would be named as my_product.
@aditi1786
@aditi1786 Год назад
I am getting error 400 Bad Request Bad Request Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)
@snzmn6270
@snzmn6270 3 года назад
You will probably get the same error when you try 'GET' for all products. Here is the solution stackoverflow.com/questions/60529230/flask-marshmallow-attributeerror-list-object-has-no-attribute-data
@jaafarnasrallah2941
@jaafarnasrallah2941 2 года назад
Thank you!!
@samarmohan9891
@samarmohan9891 3 года назад
No need for strict=True, now schemas are always strict!
@UmerPKgrw
@UmerPKgrw 3 года назад
Had a lot of issue with that then i just remove it completely and also in return just jsonfy(result)
@ericsundberg3310
@ericsundberg3310 4 года назад
# Get All Products @app.route('/product', methods=['GET']) def get_products(): all_products = Product.query.all() result = products_schema.dump(all_products) return jsonify(result.data) < ------------ there is not attribute called data so just return the result and it works
@joshuanguyen8236
@joshuanguyen8236 3 года назад
name = request.json["name"] TypeError: 'NoneType' object is not subscriptable can anyone help me with this please?
@uweopfern
@uweopfern 5 лет назад
Thats nice Brad, can yu make authentication on this API
@TraversyMedia
@TraversyMedia 5 лет назад
I will see if I can do that
@uweopfern
@uweopfern 5 лет назад
@@TraversyMedia that will be fine, and also how to deploy flask app on do with mysql db
@wdlpl
@wdlpl 5 лет назад
​@@TraversyMedia Authentication to this API, pleeeeease :)
@mahmoudtokura
@mahmoudtokura 5 лет назад
Yes you can use Flask-Login and Flask-Jwt for auth.
@IgnacioStegmayer
@IgnacioStegmayer 5 лет назад
@@TraversyMedia yes please! this is exactly what I want to learn!
@lynguist
@lynguist 3 года назад
UPDATES IN MARSHMALLOW: 1) all schemas are strict by default now - so (strict=True) is giving errors 2) result will give you the data by default now - so (result.data) is trowing an error
@starlord2388
@starlord2388 3 года назад
How can I get a nested json output?
@howards5205
@howards5205 5 лет назад
Thank you for providing such great content. However, I believe many of us would like to see this project expanded further. Right now, as great this tutorial might be, it's not suitable to use for any real-world application. Some things I would like to see are: breaking the app.py into multiple files to separate out the models and routes, using token authentication, implementing model relationships, etc. I hope you please consider. Thank you.
@Ambrozekwerondaa
@Ambrozekwerondaa 5 лет назад
Hi Traversy, Thanks so much for this video. I had been reading a lot and trying to get the concept of such an API but it was confusing to me mostly because many tutorials start off by putting different things in different files and then they import different modules into each other-it's just too confusing for a beginner. So thanks to God you put everything in a single file and gave us an overview. You have no idea how that is important to me.
@monkeydolla
@monkeydolla 4 года назад
Attribute data on Get All Products is not required. Should be removed so the function should read - @app.route('/product', methods=['GET']) def get_products(): all_products = Product.query.all() result = products_schema.dump(all_products) return jsonify(result) Hope this helps someone!
@АртурКамалдинов-я4ш
Спасибо!
@SinaKMaram-sv3vm
@SinaKMaram-sv3vm 4 года назад
I disliked it because even though you explained the content pretty well and your video breakdown was very neat, however, you are showing an example of doing CRUD and has nothing to do with RESTFUL API. To be more specific, it is violating the Statelessness as well as Client-Service architecture type. (en.wikipedia.org/wiki/Representational_state_transfer)
@lordmelbury7174
@lordmelbury7174 2 года назад
Hi Sina, could you tell me more about this, how should I do it instead of CRUD?
@manjujha456
@manjujha456 3 года назад
touch app.py file creation command not working in vs code terminal??
@PlayRiteProductions
@PlayRiteProductions 3 года назад
If you're getting an empty object for your JSON response, you need to add the 'many' option to the 'dump' method. dump(arr_objs, many=True)
@johnnycastillo9139
@johnnycastillo9139 4 года назад
so why not use python venv? Also I got an error: TypeError: __init__() got an unexpected keyword argument 'strict'
@alannava6132
@alannava6132 4 года назад
Lo corregiste, compañero??? tengo el mismo error
@mike111615
@mike111615 4 года назад
Remove 'strict=True', by default, they are already strict
@mike111615
@mike111615 4 года назад
@@alannava6132 Eliminar 'strict = True', de forma predeterminada, ya son estrictos
@johnnycastillo9139
@johnnycastillo9139 4 года назад
@@mike111615 Gracias!
@MrMyhz
@MrMyhz 4 года назад
For a REST API I think it would be better to showcase the PATCH method for updating a product. There is a whole debate to be had about idempotence, but most of the time you do not want to supply the entire product in order to update a single field. Especially if the API is not consumed by a frontend, but utilized directly by an end-user to fetch and modify data.
@n3wtou
@n3wtou 5 лет назад
Awesome video. could you make a small video that integrates a flask backend and a react frontend. I would like to know how the data flows between both ends. More so how to send data from the frontend and receive it in the flask backend. Please if you do get a chance make a video on it. Thank you.
@UmerPKgrw
@UmerPKgrw 3 года назад
Can someone please tell what was the purpose of the below commands running on python shell. Does it create objects as well or just created the db. From app import db Db.create_all()
@mahmoudtokura
@mahmoudtokura 5 лет назад
Awesome tutorial, it clearly shows why Flask is the best framework for python API development. You can also use Flask-Restful to define your endpoints. It give you all the HTTP verbs ready, your endpoints will be called resources rather than routes. Thanks Brad for your hard work and dedication.
@12PnT12
@12PnT12 Год назад
I was introduced to FastAPI and never want to look back! It feels like a sucessor to flask: inspired by it, but adding a lot of structure and validation with parameters and type hints.
@stanleylafond4650
@stanleylafond4650 4 года назад
I'm love your tutorials, except for one thing .. You seem to assume that the viewer is familiar with similar libraries, extensions, etc to the one that is the subject of the video. That's not the case for me, and I wonder how many of your viewers are in a similar position. For example, you are constantly making references to django in this video. Unless you state at the beginning of the video that certain skills are prerequisites for taking your tutorial, I wish you wouldn't make frequent references to other packages. I don't find that helpfu.
@memodev
@memodev 4 года назад
Hello! while passing the first product by postman this console throws me this error TypeError: 'Product' object is not iterable did that happen to anyone else? you can help me?
@senned27
@senned27 5 лет назад
I would really appreciate a tutorial on how this could work with NoSQL! Great work, Brad.
@hujingtao1
@hujingtao1 4 года назад
if you guys find error: TypeError: __init__() got an unexpected keyword argument 'strict', just remove "strict=True" in app.py
@shashankvp1261
@shashankvp1261 4 года назад
Getting error in get-all method, after doing this. can you help?
@mike111615
@mike111615 4 года назад
Remove 'strict=True', by default, they are already strict
@MegaCookiecook
@MegaCookiecook 2 года назад
Still useful in 2022. Thanks so much for this tutorial. I can't believe how easy this was to implement.
@sairajdas6692
@sairajdas6692 5 лет назад
First import Product class, then import db, otherwise db.create_all() won't create the database. >>>from app import Product >>>from app import db >>>db.create_all()
@zb2747
@zb2747 2 года назад
Thank you! I’m coming from node web backends and just tryna switch it up and start using python instead. Most tutorials were just brushing over the basics without explaining and getting straight to the point. Thank you brad, you’re THE best!
@nerdydad8544
@nerdydad8544 4 года назад
I keep getting the error "ModuleNotFound" with flask_sqlalchemy and flask_marshmallow. Need help!!
@selimatasever4112
@selimatasever4112 4 года назад
Press "Ctrl + Shift + P" : Show all commands Type: "Configure Language Specific …", then pick "Python" "settings.json" will open. Check in this json file if there is a line like this: {"python.jediEnabled": false} If yes, then comment it out, then reload VSCode, the problem should be solved
@АлександрОнуфриенко-ф5у
Marshmallow can on the fly update db models. That means instead of product.name = request.json.get("name") product.description = ... You can use (but you should update your schema with option sqla_session github.com/marshmallow-code/marshmallow-sqlalchemy#generate-marshmallow-schemas) product_schema = ProductSchema() response = product_schema.load(request.json, session=db.session) if response.errors: return jsonify(response.errors), 400 else: db.session.commit() # optional db.session.refresh(response.data) return jsonify({"product": response.data}), 201 Or extend ModelSchema like this (and db.session will be passed to subclasses of BaseSchema automaticly marshmallow-sqlalchemy.readthedocs.io/en/latest/recipes.html#base-schema-ii): class BaseOpts(ModelSchemaOpts): def __init__(self, meta): if not hasattr(meta, 'sql_session'): meta.sqla_session = db.session super(BaseOpts, self).__init__(meta) class BaseSchema(ModelSchema): OPTIONS_CLASS = BaseOpts
@TheCodebookInc
@TheCodebookInc 5 лет назад
I really love Flask coz it's is similar to express when it comes to build apis but I would love to watch a video with authentication added to this via Rest. Anyways your contents are making our lives in this competitive world easier. Thanks teacher
@josiel.delgadillo
@josiel.delgadillo 5 лет назад
Is anybody receiving the "TypeError: 'NoneType' object is not subscriptable" error?
@arunaravindpm
@arunaravindpm 4 года назад
If you are trying to receive data from frontend along with API as data, use name = request.form.get('name') ==> instead of ==> name = request.json['name']
@malamhari_
@malamhari_ 4 года назад
@@arunaravindpm still not work, I mean it works but the value of each key pair will be null. I wonder why
@malamhari_
@malamhari_ 4 года назад
Forget it, now it works just like in the tutorial without changing anything-_-
@joaovitorandrade1853
@joaovitorandrade1853 3 года назад
I'm getting this error. Any ideas? sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 0 - probably unsupported type.
@debojyotichatterjee4421
@debojyotichatterjee4421 3 года назад
In the get all products function what is the importance of the keyword "dump"?? I tried return products_schema.jsonify(all_items) and it works fine. Can anyone help me understand?
@adriansun2999
@adriansun2999 5 лет назад
I love this; that you make real projects now days that are more "complete" and not just 'frontend', but I would like to see more front-end, please. E.g. you could explain how 'content: ""' works when people use it "before" and "after" when they do these seemingly magic stuff. How does it work? Looks like magic to me, and would like to know more about it.
@sarojpaudel7479
@sarojpaudel7479 3 года назад
Doenst FLash has some framework for API just like DJango Rest Framework for Django?? We can use this jsonify in DJnago too I guess. But I need the framework for Flask.
@IGEDEWICAKSANA
@IGEDEWICAKSANA 5 лет назад
Thank you Brad, i learn anything from node js, react js, and today currently learn python(flask) from you. I prefer with how you teach some thing
@nebiyebulan9242
@nebiyebulan9242 2 года назад
great video, I have a question. If I give an example, I have a user table and a vehicle table user and my vehicle table are one-to-many linked. When I get my user table, the vehicle's id comes. How do I get all the values ​​of the vehicle to be listed, not just the id?
@barax9462
@barax9462 4 года назад
what happens exactly if i put method=[Delete] but within the handler i just updated a record instead of deleting...?? or generally the handler performing a task without considering the method. Beacuse to me it seems that the http-method is just a convention im confused.
@kingportipher4469
@kingportipher4469 3 месяца назад
If you have an empty json output after post request, Change the "Fields" to "fields" in the product schema
@alejandroc1172
@alejandroc1172 5 лет назад
27:23 postman give me "'list' object has no attribute 'data'" . It didn't reveal the list that in the video
@MrPoime
@MrPoime 5 лет назад
I found the sollution. Just remove the 'data' and return only jsonify(result).
@diegoigr7
@diegoigr7 5 лет назад
@@MrPoime thanks man, that worked smoothly :)
@Dennis12869
@Dennis12869 3 года назад
from flask import Flask doesn't work for me. I did everything how you did it in the video, but vs code can't find flask.
@mahmudulhassan9043
@mahmudulhassan9043 5 лет назад
Ohhhh Thankssss Brad .You are the best .I am just Searching for this tutorial ......Love you man...
@_torgeek9108
@_torgeek9108 4 года назад
I can't get this to work. I've installed all the necessary dependencies and pulled the code from Github in my attempts to troubleshoot the problem. The interpreter keeps on complaining about the strict in the ProductSchema(strict=True). Anyone who has an idea of what I have to do to sort this out please help 😣
@mike111615
@mike111615 4 года назад
Remove 'strict=True', by default, they are already strict
@byn1975
@byn1975 4 года назад
For "return jsonify(result.data)", I'm getting error: "AttributeError: 'dict' object has no attribute 'data' // Werkzeug Debugger". Can you advise on how to overcome it?
@graceokolo3036
@graceokolo3036 4 года назад
it is apparently not a dict when you print result, but a list. so do "return jsonify(result)" instead :)
@saartaranus2123
@saartaranus2123 5 лет назад
Hi Brad! first, another great and informative tutorial, thank you so much for your effort!. Second, I think that you have a small mistake - at ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-PTZiDnuC86g.html you ran the project with the command "python app.py" meaning you ran it using the global packages installed on your computer, I think you should have run it with "pipenv run app.py", which means that the project runs using the locally installed packages.
@bikky.magick
@bikky.magick 4 года назад
He is running python app.py command in the virtual environment so i guess he is right
@priyankakapale5078
@priyankakapale5078 2 года назад
thanks. I was getting error like flask module is not recognised. pipenv run app.py solved that error
@janneniemensivu475
@janneniemensivu475 5 лет назад
Excellent tutorial. So far I have not figured out how to place classes in a separate file. Any suggestions on that?
@本名出さない設定
@本名出さない設定 2 года назад
Thanks from Japan. Your video is very useful to me. Thank you very much.
@shashikanth8605
@shashikanth8605 5 лет назад
It's showing an error like "Instance of 'SQLAlchemy' has no 'Column' member" what should i do ?
@chadelofson1637
@chadelofson1637 5 лет назад
Thanks for a quick introduction to Flask REST API. I am working on a React/Flask application for IT Inventory system. I was looking for something quick on Flask REST API development.
@smallboy5400
@smallboy5400 4 года назад
video has been old. ALot of problem while coding by watching brad vode.
@ljrahn5619
@ljrahn5619 3 года назад
Great video as always! Anyone else having this issue when posting the products? 400 Bad Request Bad Request Failed to decode JSON object: Expecting value: line 1 column 1 (char 0) I believe the issue may lie with the request object when we are decode those values. I have reduced the /product endpoint to just evaluate the json body into variables and still getting this response. Note that I have made sure my header is properly Content-Type : application/json in postman.
@ljrahn5619
@ljrahn5619 3 года назад
Edit: tried with curl: curl -i -H "Content-Type: application/json" -X POST -d '{"name":"Product 2", "description":"This is product two", "price":230.50, "qty":31}' 127.0.0.1:9000/product/ . and it worked as expected. I guess originally i had taken out some of the auto generated postman headers, and upon putting those headers back it worked with postman. So anyone having this issue make sure you leave the autogenerated postman headers
Далее
Intro To Web Scraping With Python
25:48
Просмотров 201 тыс.
Build your first REST API with Flask and PostgreSQL
27:42
100 Identical Twins Fight For $250,000
35:40
Просмотров 44 млн
КАК БОМЖУ ЗАРАБОТАТЬ НА ТАЧКУ
1:36:32
FastAPI, Flask or Django - Which Should You Use?
9:49
SQLAlchemy Makes Using Python Databases EASY
19:08
Просмотров 2,2 тыс.
Minimal Flask REST API in Python
25:37
Просмотров 43 тыс.
SQLAlchemy: The BEST SQL Database Library in Python
16:39
SQLAlchemy Turns Python Objects Into Database Entries
22:23
Python Flask From Scratch - [Part 1] - Getting Started
28:48
Python REST API Tutorial - Building a Flask REST API
1:14:01