How to start Python Flask REST API
If you haven't start with Python flask lets start with me. Lets understand what is Flask ?
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
- Installed Flask :
pip install -U Flask
- Create project folder "TestAPI"
- Create file call
app.pythis will works as application i am using this file name as root or base file of project.
- Create simple code :
from flask import Flask app = Flask(__name__) def hello(): return "Welcome to Flask World!😃"
- 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.