Skip to content

Commit

Permalink
bit of cleanup and experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
tblanarik committed Sep 9, 2024
1 parent 663d58e commit d42b2d1
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions function_app.py
Original file line number Diff line number Diff line change
@@ -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
)
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)

0 comments on commit d42b2d1

Please sign in to comment.