Skip to content

Commit a9fa821

Browse files
committed
feat: update starter files
1 parent 7c091d1 commit a9fa821

File tree

2,000 files changed

+353028
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,000 files changed

+353028
-33
lines changed

NeighborlyAPI/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local.settings.json

NeighborlyAPI/.funcignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git*
2+
.vscode
3+
local.settings.json
4+
test
5+
.venv

NeighborlyAPI/.gitignore

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
.hypothesis/
51+
.pytest_cache/
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
db.sqlite3
61+
62+
# Flask stuff:
63+
instance/
64+
.webassets-cache
65+
66+
# Scrapy stuff:
67+
.scrapy
68+
69+
# Sphinx documentation
70+
docs/_build/
71+
72+
# PyBuilder
73+
target/
74+
75+
# Jupyter Notebook
76+
.ipynb_checkpoints
77+
78+
# IPython
79+
profile_default/
80+
ipython_config.py
81+
82+
# pyenv
83+
.python-version
84+
85+
# pipenv
86+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
88+
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
89+
# install all needed dependencies.
90+
#Pipfile.lock
91+
92+
# celery beat schedule file
93+
celerybeat-schedule
94+
95+
# SageMath parsed files
96+
*.sage.py
97+
98+
# Environments
99+
.env
100+
.venv
101+
env/
102+
venv/
103+
ENV/
104+
env.bak/
105+
venv.bak/
106+
107+
# Spyder project settings
108+
.spyderproject
109+
.spyproject
110+
111+
# Rope project settings
112+
.ropeproject
113+
114+
# mkdocs documentation
115+
/site
116+
117+
# mypy
118+
.mypy_cache/
119+
.dmypy.json
120+
dmypy.json
121+
122+
# Pyre type checker
123+
.pyre/
124+
125+
# Azure Functions artifacts
126+
bin
127+
obj
128+
appsettings.json
129+
local.settings.json
130+
.python_packages
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import azure.functions as func
2+
import pymongo
3+
4+
def main(req: func.HttpRequest) -> func.HttpResponse:
5+
6+
request = req.get_json()
7+
8+
if request:
9+
try:
10+
url = "localhost" # TODO: Update with appropriate MongoDB connection information
11+
client = pymongo.MongoClient(url)
12+
database = client['azure']
13+
collection = database['advertisements']
14+
15+
rec_id1 = collection.insert_one(eval(request))
16+
17+
return func.HttpResponse(req.get_body())
18+
19+
except ValueError:
20+
print("could not connect to mongodb")
21+
return func.HttpResponse('Could not connect to mongodb', status_code=500)
22+
23+
else:
24+
return func.HttpResponse(
25+
"Please pass name in the body",
26+
status_code=400
27+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"scriptFile": "__init__.py",
3+
"bindings": [
4+
{
5+
"authLevel": "anonymous",
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"name": "req",
9+
"methods": [
10+
"post"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "$return"
17+
}
18+
]
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "Azure"
3+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import azure.functions as func
2+
import pymongo
3+
from bson.objectid import ObjectId
4+
5+
6+
def main(req: func.HttpRequest) -> func.HttpResponse:
7+
8+
id = req.params.get('id')
9+
10+
if id:
11+
try:
12+
url = "localhost" # TODO: Update with appropriate MongoDB connection information
13+
client = pymongo.MongoClient(url)
14+
database = client['azure']
15+
collection = database['advertisements']
16+
17+
query = {'_id': ObjectId(id)}
18+
result = collection.delete_one(query)
19+
return func.HttpResponse("")
20+
21+
except:
22+
print("could not connect to mongodb")
23+
return func.HttpResponse("could not connect to mongodb", status_code=500)
24+
25+
else:
26+
return func.HttpResponse("Please pass an id in the query string",
27+
status_code=400)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"scriptFile": "__init__.py",
3+
"bindings": [
4+
{
5+
"authLevel": "anonymous",
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"name": "req",
9+
"methods": [
10+
"delete"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "$return"
17+
}
18+
]
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "Azure"
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import json
2+
import logging
3+
import azure.functions as func
4+
5+
6+
def main(event: func.EventGridEvent):
7+
8+
logging.info('Function triggered to process a message: ', event.get_body())
9+
logging.info(' EnqueuedTimeUtc =', event.enqueued_time)
10+
logging.info(' SequenceNumber =', event.sequence_number)
11+
logging.info(' Offset =', event.offset)
12+
13+
result = json.dumps({
14+
'id': event.id,
15+
'data': event.get_json(),
16+
'topic': event.topic,
17+
'subject': event.subject,
18+
'event_type': event.event_type,
19+
})
20+
21+
22+
logging.info('Python EventGrid trigger processed an event: %s', result)
23+
24+
25+

0 commit comments

Comments
 (0)