Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from flask import Flask
app = Flask(__name__)
@app.route('/')
def indexFn():
return '''
<html>
<head>
<title>Calculadora</title>
</head>
<body>
<h1>La calculadora de cibernóadas</h1>
<p>
Esto es una calculadora muy sencilla. Solo adminte sumas y restas.
</p>
<p>
Por ejemplo, si quieres sumar dos números tienes que navegar a <a href="/suma/100/10">/suma/100/10</a>
</p>
<p>
Por el contrario, si quieres restar tienes que navegar a <a href="/resta/100/10">/resta/100/10</a>
</p>
</body>
</html>'''
@app.route('/suma/<int:num_a>/<int:num_b>')
def sumaFn(num_a, num_b):
return "{}".format(num_a + num_b)
@app.route('/resta/<int:num_a>/<int:num_b>')
def restaFn(num_a, num_b):
return "{}".format(num_a - num_b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.