Introducing Flask and Flask-RESTful
Flask
is a lightweight framework for building web applications. It enables you to start simple and scale when needed. Flask-RESTful
is an extension for Flask
that allows you to build REST APIs in no time.
To get started with these two, you'll need to install them. You can execute the following line from the terminal:
> pip install flask flask-restful
And that's all you need to get started. Let's explore the basics of Flask
first:
- Believe it or not, you'll need only seven lines of code to create your first web application with
Flask
. It won't do anything useful, but it's still a step in the right direction.To start, you'll need to import the library and create an application instance. You'll then have to make a function that returns what you want to be displayed on the website and decorate the function with an
@app.route(route_url)
decorator. Keep in mind that you should replaceroute_url...