Así que tengo una ruta api similar a la que se muestra a continuación. Toma un comando sql y luego lo ejecuta, luego devuelve el valor en formato json. Quiero hacer esto cuando se realiza una entrada en una página web de JavaScript. es algo que es posible
@app.route('/api/getdata', methods = ['GET']) def insert_restaurant(): getuser = "SELECT name FROM restaurants ORDER BY RAND() LIMIT 1;" # This statement witll return the random restaurant tha the users have entered conn = create_connection("", "", "", "") getting_users = execute_read_query(conn, getuser) return jsonify(getting_users)la forma en que estoy aprendiendo las cosas del nodo js es similar a esto. cuando se complete el formulario, irá al sitio web, buscará y luego devolverá el resultado
app.post('/process_form', function(req, res){ // create a variable to hold the username parsed from the request body var search = req.body.search // Now we will use the token wiht the name that the user entered // For this we will use the axios method to return the result axios.get('https://itunes.apple.com/search?term='+search) .then((response)=>{ var songlist = response.data.results; console.log(songlist); // Now we will execute the results in the page named thanks res.render('pages/thanks.ejs', { songlist: songlist, search: search }); }); });¿Cómo puedo implementar el primer comando para que se ejecute como el segundo comando? ¿Tiene sentido lo que estoy diciendo? estoy perdido