How to start Python Flask REST API

How to start Python Flask REST API

ยท

2 min read

If you haven't start with Python flask lets start with me. Lets understand what is Flask ? Flask Image

Flask is lightweight Python framework support as web interface. If you would like to create REST API or web interface Flask will you help to kick start as fast as possible. Like Python, Flask has larger communities and extra plugins available to enhance features. And its third party Python library.

Perquisites: Python 2.x or 3.x

  1. Installed Flask : pip install -U Flask
  2. Create project folder "TestAPI"
  3. Create file call app.py this will works as application i am using this file name as root or base file of project.
  4. Create simple code :
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Welcome to Flask World!๐Ÿ˜ƒ"
  1. Run application
$ env FLASK_APP=app.py flask run
 * Serving Flask app "app"
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Here is your first initial Flask running project.

I have created one sample REST API project using Flask framework.

This project can take as reference for project structure and how error handling can be done. What are naming convention can be used.

Feel free to ask any question. Can reach out to my twitter handler.

Reference : flask.palletsprojects.com/en/1.1.x opensource.com/article/18/4/flask realpython.com/tutorials/flask

Did you find this article valuable?

Support Avinash Dalvi by becoming a sponsor. Any amount is appreciated!

ย