Skip to content

Commit a0bcd62

Browse files
committed
chore: add sample for Https functions & Flask
1 parent f7eb95e commit a0bcd62

File tree

8 files changed

+142
-0
lines changed

8 files changed

+142
-0
lines changed

samples/https_flask/.firebaserc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "python-functions-testing"
4+
}
5+
}

samples/https_flask/.gitignore

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
firebase-debug.log*
8+
firebase-debug.*.log*
9+
10+
# Firebase cache
11+
.firebase/
12+
13+
# Firebase config
14+
15+
# Uncomment this if you'd like others to create their own Firebase project.
16+
# For a team working on the same Firebase project(s), it is recommended to leave
17+
# it commented so all members can deploy to the same project(s) in .firebaserc.
18+
# .firebaserc
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
32+
# nyc test coverage
33+
.nyc_output
34+
35+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
36+
.grunt
37+
38+
# Bower dependency directory (https://bower.io/)
39+
bower_components
40+
41+
# node-waf configuration
42+
.lock-wscript
43+
44+
# Compiled binary addons (http://nodejs.org/api/addons.html)
45+
build/Release
46+
47+
# Dependency directories
48+
node_modules/
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Optional REPL history
57+
.node_repl_history
58+
59+
# Output of 'npm pack'
60+
*.tgz
61+
62+
# Yarn Integrity file
63+
.yarn-integrity
64+
65+
# dotenv environment variables file
66+
.env

samples/https_flask/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Required to avoid a 'duplicate modules' mypy error
2+
# in monorepos that have multiple main.py files.
3+
# https://github.com/python/mypy/issues/4008

samples/https_flask/firebase.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"functions": [
3+
{
4+
"source": "functions",
5+
"codebase": "default",
6+
"ignore": [
7+
"venv"
8+
]
9+
}
10+
]
11+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# pyenv
2+
.python-version
3+
4+
# Installer logs
5+
pip-log.txt
6+
pip-delete-this-directory.txt
7+
8+
# Environments
9+
.env
10+
.venv
11+
venv/
12+
venv.bak/
13+
__pycache__
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Flask & Firebase Functions Example
2+
3+
Getting started locally:
4+
5+
```bash
6+
python3.10 -m venv venv
7+
source venv/bin/activate
8+
pip3 install --upgrade pip
9+
python3.10 -m pip install -r requirements.txt
10+
```

samples/https_flask/functions/main.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Example Firebase Functions with Flask.
3+
"""
4+
5+
from flask import Flask
6+
from functions_wrapper import entrypoint
7+
8+
from firebase_functions import https_fn
9+
10+
app = Flask(__name__)
11+
12+
13+
@app.route("/hello")
14+
def hello():
15+
return "Hello!"
16+
17+
18+
@app.route("/world")
19+
def world():
20+
return "Hello World!"
21+
22+
23+
@https_fn.on_request()
24+
def httpsflaskexample(request):
25+
return entrypoint(app, request)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Not published yet,
2+
# firebase-functions-python >= 0.0.1
3+
# so we use a relative path during development:
4+
# ./../../../
5+
# Or switch to git ref for deployment testing:
6+
git+https://github.com/firebase/firebase-functions-python.git@main#egg=firebase-functions
7+
8+
firebase-admin >= 6.0.1
9+
functions_wrapper >= 1.0.1

0 commit comments

Comments
 (0)