Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
[Cloud Tasks] Add task with authentication sample [(#2113)](GoogleClo…
Browse files Browse the repository at this point in the history
…udPlatform/python-docs-samples#2113)

* Add task with authentication sample

* Fix linting

* Fix linting

* Fix spacing

* Update tests with service account

* Move samples and update READMEs

* Update version and linting
  • Loading branch information
averikitsch authored Apr 18, 2019
1 parent 052b45a commit e7e1243
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
17 changes: 17 additions & 0 deletions samples/appengine/flexible/tasks/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official Python image.
# https://hub.docker.com/_/python
FROM python:3.7

# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . .

# Install production dependencies.
RUN pip install Flask gunicorn

# Run the web service on container startup. Here we use the gunicorn
# webserver, with one worker process and 8 threads.
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 main:app
21 changes: 0 additions & 21 deletions samples/appengine/flexible/tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,3 @@ endpoint, with a payload specified:
```
python create_app_engine_queue_task.py --project=$PROJECT_ID --queue=$QUEUE_ID --location=$LOCATION_ID --payload=hello
```

### Using HTTP Push Queues

Set an environment variable for the endpoint to your task handler. This is an
example url to send requests to the App Engine task handler:
```
export URL=https://<project_id>.appspot.com/example_task_handler
```

Running the sample will create a task and send the task to the specific URL
endpoint, with a payload specified:

```
python create_http_task.py --project=$PROJECT_ID --queue=$QUEUE_ID --location=$LOCATION_ID --url=$URL --payload=hello
```

Now view that the payload was received and verify the payload:

```
gcloud app logs read
```
2 changes: 1 addition & 1 deletion samples/appengine/flexible/tasks/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Flask==1.0.2
gunicorn==19.9.0
google-cloud-tasks==0.6.0
google-cloud-tasks==0.7.0

0 comments on commit e7e1243

Please sign in to comment.