File tree Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ pip install -r requirements.txt
60
60
func start
61
61
```
62
62
63
- 2 ) Test the HTTP GET trigger using the browser to open [ http://localhost:7071/api/httpGetFunction ] ( http://localhost:7071/api/http_get )
63
+ 2 ) Test the HTTP GET trigger using the browser to open [ http://localhost:7071/api/http_get ] ( http://localhost:7071/api/http_get )
64
64
65
65
3 ) Test the HTTP POST trigger in a new terminal window:
66
66
``` bash
@@ -82,17 +82,11 @@ The key code that makes tthese functions work is in `function_app.py`. The func
82
82
` ` ` python
83
83
@app.route(route=" http_get" , methods=[" GET" ])
84
84
def http_get(req: func.HttpRequest) -> func.HttpResponse:
85
- name = req.params.get(" name" )
86
-
85
+ name = req.params.get(" name" , " World " )
86
+
87
87
logging.info(f" Processing GET request. Name: {name}" )
88
88
89
- if name:
90
- return func.HttpResponse(f" Hello, {name}!" )
91
- else:
92
- return func.HttpResponse(
93
- " Please pass a 'name' parameter in the query string" ,
94
- status_code=400
95
- )
89
+ return func.HttpResponse(f" Hello, {name}!" )
96
90
` ` `
97
91
This code shows a HTTP POST triggered function.
98
92
Original file line number Diff line number Diff line change 5
5
6
6
@app .route (route = "http_get" , methods = ["GET" ])
7
7
def http_get (req : func .HttpRequest ) -> func .HttpResponse :
8
- name = req .params .get ("name" )
9
-
8
+ name = req .params .get ("name" , "World" )
9
+
10
10
logging .info (f"Processing GET request. Name: { name } " )
11
11
12
- if name :
13
- return func .HttpResponse (f"Hello, { name } !" )
14
- else :
15
- return func .HttpResponse (
16
- "Please pass a 'name' parameter in the query string" ,
17
- status_code = 400
18
- )
12
+ return func .HttpResponse (f"Hello, { name } !" )
19
13
20
14
@app .route (route = "http_post" , methods = ["POST" ])
21
15
def http_post (req : func .HttpRequest ) -> func .HttpResponse :
You can’t perform that action at this time.
0 commit comments