Python REST API Tutorial - Building a Flask REST API

Tech With Tim · 843K views · 2020 · 1:14:01

Open on YouTube

Web developmentPython, Ruby & scripting languagestutorial

Why Stack Overflow recommends it

Stack Overflow users link it as a beginner walkthrough for building a Flask REST API, and many askers say they were following it when they hit errors in their own code.

Recommended by 1 people across 1 different months, 2020 to 2024.

What it is

A 74-minute tutorial from Tech With Tim that builds a Python REST API with Flask and Flask-RESTful, starting from a Hello World endpoint and moving through request parsing, status codes and validation. It then adds a Flask-SQLAlchemy database with models, serialization, and create, update and delete handlers.

What people said

Recommends Samrat Sahoo · 2020-11 · Stack Overflow · on “How can I run a Python script from within a React Native app?”

The easiest way would probably be to make a REST API using something like Flask and then send HTTP requests from React Native to your API. If you are new to Flask and REST APIs, I would suggest checking this video [this video] out. Flask Homepage [LINK]

Cites jadside · 2022-07 · Stack Overflow · on “Flask-Restful Error: request Content-Type was not 'application/json'."}”

I was following this tutorial [this video] and it was going pretty well. He then introduced reqparse and I followed along. I tried to test my code and I get this error {'message': "Did not attempt to load JSON data because the request Content-Type was not 'application/json'."} I don't know if I'm missing something super obvious but I'm pretty sure I copied his code exactly. here's the code: main.py from flask import Flask, request from flask_restful import Api, Resource, reqparse app = Flask(__name__) api = Api(app) #basic get and post names = {"sai": {"age": 19, "gender": "male"}, "bill": {"age": 23, "gender": "male"}} class HelloWorld(Resource): def get(self, name, numb): return names[name] def

Cites brian valladares · 2023-05 · Stack Overflow · on “"cannot import name 'EVENT_TYPE_OPENED' from 'watchdog.events' "”

I'm trying to make a REST api (begginer) but when i tried to initialize the server from this code: from flask import Flask app = Flask(__name__) if __name__=='__main__': app.run(debug=True, port=4000) i get this error in the prompt: from watchdog.events import EVENT_TYPE_OPENED ImportError: cannot import name 'EVENT_TYPE_OPENED' from 'watchdog.events' (C:\ ********* \Python\Python310\lib\site-packages\watchdog\events.py) I'm expecting something like this (Min 8:27): [this video]

Cites Tom Bird · 2024-09 · Stack Overflow · on “Python project with flask doesn't think I have a email column for some reason”

I've been trying to follow this tutorial [this video] but I changed my code slightly to understand better, but I'm getting a error that there is a missing column when I'm trying to create a new resource via a post request, I'm utilizing flask , flask_restful and flask_alchemy Model definition: class UserModel(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) email = db.Column(db.String(100), nullable=False) def __repr__(self): return f"User(name={name}, email={email})" User class definition: # user class class User(Resource): @marshal_with(resource_fields_user) def get(self, user_id): result = UserModel.query.get(id=user_id) return {"request_