When I start the flask server, it shows no error, but it tell “The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.”
<code>from flask import Flask, request, jsonify
from sql_connection import get_sql_connection
import products_dao
app = Flask(__name__)
connection = get_sql_connection()
@app.route("/getProducts", methods=['GET'])
def get_products():
products = products_dao.get_all_products(connection)
response = jsonify(products)
response.headers.add('Access-Control-Allow-Origin', '*')
return response
if __name__ == '__main__':
print("Server started")
app.run(port=5000)
</code>
<code>from flask import Flask, request, jsonify
from sql_connection import get_sql_connection
import products_dao
app = Flask(__name__)
connection = get_sql_connection()
@app.route("/getProducts", methods=['GET'])
def get_products():
products = products_dao.get_all_products(connection)
response = jsonify(products)
response.headers.add('Access-Control-Allow-Origin', '*')
return response
if __name__ == '__main__':
print("Server started")
app.run(port=5000)
</code>
from flask import Flask, request, jsonify
from sql_connection import get_sql_connection
import products_dao
app = Flask(__name__)
connection = get_sql_connection()
@app.route("/getProducts", methods=['GET'])
def get_products():
products = products_dao.get_all_products(connection)
response = jsonify(products)
response.headers.add('Access-Control-Allow-Origin', '*')
return response
if __name__ == '__main__':
print("Server started")
app.run(port=5000)
The opened window is supposed to show all the product details
New contributor
Liya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.