예제 #1
0
파일: quizz.py 프로젝트: vanzaj/BeeFriendly
def garden_quizz():
    with flask_to_scope(flask_tracer, request) as scope:
        if request.method == 'POST':
            params = json.loads(request.data)
            garden_size = params['selected_garden_size']
            flowers = params['selected_flowers']
            score = calculate_score(garden_size, flowers)
            opentracing.tracer.active_span.set_tag('response', score)
            return jsonify({"score": score})
예제 #2
0
def handle_format_greeting():
    with flask_to_scope(flask_tracer, request) as scope:
        name = request.args.get('name')
        title = request.args.get('title')
        descr = request.args.get('description')
        return format_greeting(
            name=name,
            title=title,
            description=descr,
        )
예제 #3
0
def flower_scorer():
    with flask_to_scope(flask_tracer, request) as scope:
        #parse_baggage(request.headers, scope)
        if request.method == 'POST':
            params = json.loads(request.data)
            print(f"got form data {params.keys()}")
            garden_size = params['selected_garden_size']
            flowers = params['selected_flowers']
            score = calculate_score(garden_size, flowers)
            opentracing.tracer.active_span.set_tag('response', score)
            return jsonify({"score": score})
예제 #4
0
def get_flower_http(name):
    with flask_to_scope(flask_tracer, request) as scope:
        flower = Flower.get(name)
        if flower is None:
            flower = Flower()
            flower.name = name
            flower.flowering_months = "june"

        result = {
            'name': flower.name,
            'flowering_months': flower.flowering_months.split(","),
            'description': flower.description,
        }

        opentracing.tracer.active_span.log_kv(result)
        return json.dumps(result)
예제 #5
0
파일: users.py 프로젝트: vanzaj/BeeFriendly
def get_person_http(name):
    with flask_to_scope(flask_tracer, request) as scope:
        person = Person.get(name)
        if person is None:
            if name in ["Neonicotinoid", "Insecticide", "DDT"]:
                raise Exception(f"{name}s are not kind to bees.")
            person = Person()
            person.name = name
        else:
            person.description
        response = {
            'name': person.name,
            'title': person.title,
            'description': person.description,
        }
        opentracing.tracer.active_span.log_kv(response)
        return json.dumps(response)
예제 #6
0
def get_flower_http(name):
    with flask_to_scope(flask_tracer, request) as scope:
        flower = Flower.get(name)
        if flower is None:
            flower = create_flower(name)

        if flower.name == "rhododendron":
            raise Exception(
                "Rhododendron causes a crash! Congratulations, you found a bug."
            )
        else:
            result = {
                'name': flower.name,
                'flowering_months': flower.flowering_months.split(","),
                'description': flower.description,
            }

        opentracing.tracer.active_span.log_kv(result)
        return json.dumps(result)
예제 #7
0
def say_hello(name):
    with flask_to_scope(flask_tracer, request) as scope:
        person = get_person(name)
        resp = format_greeting(person)
        opentracing.tracer.active_span.set_tag('response', resp)
        return resp