Building a REST API using Python and Flask | Flask-RESTful

Melvin L · 321K views · 2018 · 15:21

Open on YouTube

Web developmentPython, Ruby & scripting languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they followed when asking why their Flask or Flask-RESTful code throws import or setup errors.

Recommended by 0 people across 0 different months, 2018 to 2019.

What it is

A 15-minute tutorial by Melvin L showing how to build a REST API in Python with Flask. It demos two approaches: using Flask alone, and using the Flask-RESTful extension.

What people said

Cites BlockchainProgrammer · 2018-07 · Stack Overflow · on “flask_restful import Resource error”

I did the following tutorial on youtube: [this video] This is my code: from flask import Flask, request from flask_restful import Resource, Api app = Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'about':'Hello World!'} def post(self): some_json = request.get_json() return {'you sent': some_json}, 201 class Multi(Resource): def get(self, num): return {'result': num*10} api.add_resource(HelloWorld, '/') api.add_resource(Multi, '/multi/<int:num>') if __name__ == '__main__': app.run(debug=True) Now when I run the script, I get following error: /home/one/systemx/test_api$ python flask_restful.py Traceback (most recent call last): File "flask_restful.py", line 2, in

Cites reinhardt · 2019-11 · Stack Overflow · on “Error while building a RESTApi using flask_restful”

Flask RESTApi newbie here I am trying to build a RESTapi service in Flask (and I am trying to save the output as a .txt file) using flask_restful for a code of mine using the pydifact [LINK] module as follows: import datetime from pydifact.message import Message from pydifact.segments import Segment from flask import Flask, request from flask_restful import Resource, Api app = Flask(__name__) api = Api(app) class RestAPI(Resource): def get(self, ABSENDER_ID, EMPFÄNGER_ID, ERSTELLUNG_DATUM_ZEIT, REFERENCE): MSCONS = Message() def erstellung_datum_zeit(dt_time): # Needed for the UNB segment dt_time = dt_time.strftime('%Y%m%d%H%M') return dt_time def UNA_UNB_segment(absender_id, empfänger_id, e

Cites Diego Vente Seminario · 2019-12 · Stack Overflow · on “Python - Flask is not recognized, after imported”

I'm trying to create a rest api with python-flask by following this video: [this video] However, after installing flask with: pip3 install flask , and executing it in the console with: python app.py and py app.py , it throws the following error: Traceback (most recent call last): File "app.py", line 1, in <module> from flask import Flask ImportError: No module named flask PS C:\Users\THEROG\Desktop\products-restapi> This is the code: from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello world" if __name__ == '__main__': app.run(debug= True) Here is the screen of the output: [LINK]