From d42b2d1bf896df43851f30a9e34dde9a898d815f Mon Sep 17 00:00:00 2001 From: Trevor Blanarik Date: Mon, 9 Sep 2024 07:14:37 +0000 Subject: [PATCH] bit of cleanup and experimenting --- function_app.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/function_app.py b/function_app.py index 4b26493..9061652 100644 --- a/function_app.py +++ b/function_app.py @@ -1,25 +1,23 @@ import azure.functions as func import logging +import requests +import os app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION) -@app.route(route="http_trigger1") -def http_trigger1(req: func.HttpRequest) -> func.HttpResponse: +@app.route(route="spotbot", methods=[func.HttpMethod.POST]) +def spotbot(req: func.HttpRequest) -> func.HttpResponse: logging.info('Python HTTP trigger function processed a request.') - name = req.params.get('name') - if not name: - try: - req_body = req.get_json() - except ValueError: - pass - else: - name = req_body.get('name') - - if name: - return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") + try: + req_body = req.get_json() + except ValueError: + pass else: - return func.HttpResponse( - "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", - status_code=200 - ) \ No newline at end of file + name = req_body.get('name') + + content = {"content": "TESTING 123"} + + target_url = os.getenv('TARGET_URL') + response = requests.post(target_url, json=content) + return func.HttpResponse(response.text, status_code=response.status_code) \ No newline at end of file