Skip to content

Commit 353f025

Browse files
authored
updated again
1 parent daf3267 commit 353f025

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

articles/azure-functions/functions-reference-python.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,30 +409,32 @@ Update the Python code file `init.py`, depending on the interface used by your f
409409
# [ASGI](#tab/asgi)
410410

411411
```python
412-
app=FastAPI("Test")
412+
app=fastapi.FastAPI()
413413

414-
@app.route("/api/HandleApproach")
415-
def test():
416-
return "Hello!"
414+
@app.get("/hello/{name}")
415+
async def get_name(
416+
name: str,):
417+
return {
418+
"name": name,}
417419

418-
def main(req: func.HttpRequest, context) -> func.HttpResponse:
419-
logging.info('Python HTTP trigger function processed a request.')
420-
return func.AsgiMiddleware(app).handle(req, context)
420+
def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
421+
return AsgiMiddleware(app).handle(req, context)
421422
```
422423

423424
# [WSGI](#tab/wsgi)
424425

425426
```python
426427
app=Flask("Test")
427428

428-
@app.route("/api/WrapperApproach")
429-
def test():
430-
return "Hello!"
429+
@app.route("/hello/<name>", methods=['GET'])
430+
def hello(name: str):
431+
return f"hello {name}"
431432

432433
def main(req: func.HttpRequest, context) -> func.HttpResponse:
433434
logging.info('Python HTTP trigger function processed a request.')
434435
return func.WsgiMiddleware(app).handle(req, context)
435436
```
437+
For a full example, see [Using Flask Framework with Azure Functions](https://docs.microsoft.com/en-us/samples/azure-samples/flask-app-on-azure-functions/azure-functions-python-create-flask-app/).
436438

437439
---
438440

0 commit comments

Comments
 (0)