Pytest with Docker - application
This is the Flask-based web application.
The main page returns some text.
The ’/api/calcURL accepts 2 parameters:aandb` with two numbers.
It returns a JSON with these values and their sum.
from flask import Flask, jsonify, request
import time
calcapp = Flask(__name__)
@calcapp.route("/")
def main():
return 'Send a GET request to /api/calc and get a JSON response.'
@calcapp.route("/api/calc")
def add():
a = int(request.args.get('a', 0))
b = int(request.args.get('b', 0))
return jsonify({
"a" : a,
"b" : b,
"add" : a+b,
})