Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda