Skip to content

Commit

Permalink
Updated to Flask 1.0 (#1819)
Browse files Browse the repository at this point in the history
  • Loading branch information
magdazk authored and engelke committed Nov 20, 2018
1 parent 981737e commit d52ccf9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions functions/concepts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def statelessness(request):
within a specific instance.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
global count
count += 1
Expand Down Expand Up @@ -62,11 +62,11 @@ def scope_demo(request):
HTTP Cloud Function that declares a variable.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""

# Per-function scope
Expand All @@ -82,11 +82,11 @@ def make_request(request):
HTTP Cloud Function that makes another HTTP request.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
import requests

Expand Down
16 changes: 8 additions & 8 deletions functions/helloworld/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def hello_get(request):
"""HTTP Cloud Function.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
return 'Hello, World!'
# [END functions_helloworld_get]
Expand Down Expand Up @@ -60,11 +60,11 @@ def hello_http(request):
"""HTTP Cloud Function.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
request_json = request.get_json()
if request_json and 'name' in request_json:
Expand Down Expand Up @@ -111,11 +111,11 @@ def hello_content(request):
according to the "content-type" header.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
content_type = request.headers['content-type']
if content_type == 'application/json':
Expand All @@ -137,11 +137,11 @@ def hello_method(request):
""" Responds to a GET request with "Hello world!". Forbids a PUT request.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
from flask import abort

Expand Down
4 changes: 2 additions & 2 deletions functions/http/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def parse_xml(request):
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
data = xmltodict.parse(request.data)
return json.dumps(data, indent=2)
Expand All @@ -72,7 +72,7 @@ def parse_multipart(request):
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""

# This code will process each non-file field in the form
Expand Down
2 changes: 1 addition & 1 deletion functions/log/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_log_entries(request):
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
""""""

Expand Down
10 changes: 5 additions & 5 deletions functions/tips/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def lazy_globals(request):
HTTP Cloud Function that uses lazily-initialized globals.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""
global lazy_global, non_lazy_global

Expand All @@ -89,11 +89,11 @@ def connection_pooling(request):
HTTP Cloud Function that uses a connection pool to make HTTP requests.
Args:
request (flask.Request): The request object.
<http://flask.pocoo.org/docs/0.12/api/#flask.Request>
<http://flask.pocoo.org/docs/1.0/api/#flask.Request>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""

# The URL to send the request to
Expand Down Expand Up @@ -121,7 +121,7 @@ def gcp_api_call(request):
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response>.
<http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
"""

project = os.getenv('GCP_PROJECT')
Expand Down

0 comments on commit d52ccf9

Please sign in to comment.