REST API in FLASK app and Postman:
The code:
from flask_sqlalchemy import SQLAlchemy from flask import Flask,render_template,request,jsonify,json import psycopg2 import psycopg2.extras app = Flask(__name__) db = SQLAlchemy() conn = psycopg2.connect("postgresql://postgres: postgres@localhost :5432/country") cr = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) @app.route('/', methods=['GET']) def test(): return jsonify({ 'message': 'Welcome' }) @app.errorhandler(404) def page_not_found(e): return "<h1>404</h1><p>The resource could not be found.</p>", 404
Result:
**
Sankar guru
source share