Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
how do I make a math Django and react web application?

Hope all is well.

I want to have an input field in my react frontend that takes in a math expression (e.g 1 + 1) and I want my backend to respond with the answer 2.

How do you do this using reactjs and Django?

So far I have some of the frontend finished:

it will send the input data to the backend using the API url.

import  React, {useState, UseEffect } from 'react';

function Home() {
    const [query, setQuery] = useState("");

    return (
        <div className='Home'>
            <form action={APIL_URL} method="POST">
                <input name="linear-algebra-expression"
                       id="linear-algebra-expression"
                       type="text"
                       onChange={e => setQuery(e.target.value)}
                       value={query}>
                </input>
            </form>
        </div>
    )
}

export default Home;

I am aware that in my Django backend I am going to have something like:

class LinearAlgebraView(APIView):
    def post(self, request):
        expression = request.POST['linear-algebra-expression']

        return (... ?)

I want to be able to return the computed data from Django to react at the samne web page where the user entered the math expression in the form/input. How do I do this?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you could just use eval() method witch taking a string as parameter and return the computed value like for exemple :

linear-algebra-expression = "3-1 + 12/10"
result = eval(linear-algebra-expression)
print(" 3-1 + 12/10 = " + str(result))

output: 3-1 + 12/10 = 3.2

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda