mirror of https://github.com/ivanch/tcc.git
31 lines
803 B
Python
31 lines
803 B
Python
from flask import request, Blueprint, jsonify
|
|
|
|
simulation_blueprint = Blueprint('simulation_blueprint', __name__)
|
|
|
|
class SimulationController:
|
|
def __init__(self):
|
|
pass
|
|
|
|
def harmonic_progression(self, n):
|
|
sum = 0
|
|
for i in range(1, n):
|
|
sum += 1/i
|
|
|
|
return sum
|
|
|
|
def return_helloworld(self):
|
|
return jsonify(message="Hello World!")
|
|
|
|
simulation_controller = SimulationController()
|
|
|
|
@simulation_blueprint.route('/simulation/harmonic-progression', methods=['GET'])
|
|
def return_ok():
|
|
n = int(request.args.get('n'))
|
|
sum = simulation_controller.harmonic_progression(n)
|
|
|
|
return str(sum), 200
|
|
|
|
@simulation_blueprint.route('/simulation/json', methods=['GET'])
|
|
def return_helloworld():
|
|
return simulation_controller.return_helloworld(), 200
|