Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import azure.functions as func
- import datetime
- import logging
- def main(req: func.HttpRequest) -> func.HttpResponse:
- logging.info('Python HTTP trigger function processed a request.')
- name = req.params.get('name')
- id = req.params.get('id')
- if not name:
- try:
- req_body = req.get_json()
- except ValueError:
- pass
- else:
- name = req_body.get('name')
- if not id:
- try:
- req_body = req.get_json()
- except ValueError:
- pass
- else:
- id = req_body.get('id')
- if name and id:
- current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- response_message = f" my id is {id} and my name is {name} date :{current_time} "
- return func.HttpResponse(response_message)
- else:
- return func.HttpResponse(
- "Need query string",
- status_code=400
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement