diff --git a/lib/plugins/create/templates/google-python/gitignore b/lib/plugins/create/templates/google-python/gitignore new file mode 100644 index 000000000..dab0e81bf --- /dev/null +++ b/lib/plugins/create/templates/google-python/gitignore @@ -0,0 +1,37 @@ +# Serverless +.serverless +.env +tmp +.coveralls.yml + +# Google +keyfile.json + +# Logs +*.log + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git +node_modules + +# IDE +**/.idea + +# OS +.DS_Store +.tmp diff --git a/lib/plugins/create/templates/google-python/main.py b/lib/plugins/create/templates/google-python/main.py new file mode 100644 index 000000000..f8ae93562 --- /dev/null +++ b/lib/plugins/create/templates/google-python/main.py @@ -0,0 +1,11 @@ +def pyhttp(request): + """Responds to any HTTP request. + Args: + request (flask.Request): HTTP request object. + Returns: + The response text or any set of values that can be turned into a + Response object using + `make_response `. + """ + return f'Hello World!' + diff --git a/lib/plugins/create/templates/google-python/package.json b/lib/plugins/create/templates/google-python/package.json new file mode 100644 index 000000000..01f15f575 --- /dev/null +++ b/lib/plugins/create/templates/google-python/package.json @@ -0,0 +1,14 @@ +{ + "name": "google-python", + "version": "0.1.0", + "description": "", + "main": "main.py", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "serverless.com", + "license": "MIT", + "devDependencies": { + "serverless-google-cloudfunctions": "*" + } +} diff --git a/lib/plugins/create/templates/google-python/serverless.yml b/lib/plugins/create/templates/google-python/serverless.yml new file mode 100644 index 000000000..af75a95f0 --- /dev/null +++ b/lib/plugins/create/templates/google-python/serverless.yml @@ -0,0 +1,48 @@ +service: gcf-python# NOTE: Don't put the word "google" in here + +provider: + name: google + stage: dev + runtime: python37 + region: us-central1 + project: my-project + # The GCF credentials can be a little tricky to set up. Luckily we've documented this for you here: + # https://serverless.com/framework/docs/providers/google/guide/credentials/ + # + # the path to the credentials file needs to be absolute + credentials: ~/.gcloud/keyfile.json + +plugins: + - serverless-google-cloudfunctions + +# needs more granular excluding in production as only the serverless provider npm +# package should be excluded (and not the whole node_modules directory) +package: + exclude: + - node_modules/** + - .gitignore + - .git/** + +functions: + first: + handler: http + events: + - http: path + # NOTE: the following uses an "event" event (pubSub event in this case). + # Please create the corresponding resources in the Google Cloud + # before deploying this service through Serverless + #second: + # handler: event + # events: + # - event: + # eventType: providers/cloud.pubsub/eventTypes/topic.publish + # resource: projects/*/topics/my-topic + +# you can define resources, templates etc. the same way you would in a +# Google Cloud deployment configuration +#resources: +# resources: +# - type: storage.v1.bucket +# name: my-serverless-service-bucket +# imports: +# - path: my_template.jinja