Posts

login code

import React , { useState } from 'react' ; import axios from 'axios' ; import { useNavigate } from 'react-router-dom' ; import './App.css' ; const LoginPage = ({ setUserName }) => {   const [ userName , setUserNameInput ] = useState ( '' );   const [ password , setPassword ] = useState ( '' );   const [ showPassword , setShowPassword ] = useState ( false );   const navigate = useNavigate ();   const validateInput = () => {     if ( ! userName || ! password ) {       alert ( 'Please enter a valid username and password.' );       setUserNameInput ( '' );       setPassword ( '' );       return false ;     }     return true ;   };   // ✅ Sign Up only stores username & password in the database   const handleSignup = async () => {     if ( ! validateInput ()) return ;     try {     ...

sample coding

app.py from flask import Flask, request, jsonify, session from flask_cors import CORS import pymysql   # MySQL library import requests from werkzeug.security import generate_password_hash, check_password_hash from retrying import retry import requests app = Flask( __name__ ) app.secret_key = '2576fa35bdb55ddfd7476f752939fa7e' CORS(app) # Database Configuration (Using pymysql) db = pymysql.connect(     host = "localhost" ,     user = "root" ,   # Replace with your MySQL username     password = "" ,   # Replace with your MySQL password     database = "recipe_finder"   # Ensure the database exists ) SPOONACULAR_API_KEY = "4cf45fa4ab174fb5bcd586e17b02a653"   # Replace with your real API key @app.route ( '/' , methods = [ 'GET' ]) def home ():     return jsonify({ "message" : "Welcome to the Recipe Finder API. Use the /find-recipes endpoint to search for recipes." }) @app.route (...