Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to flask 1.0 #1819

Merged
merged 2 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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