-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mel Cadano
committed
Aug 1, 2024
1 parent
691e017
commit 06653a9
Showing
12 changed files
with
128 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.git* | ||
.vscode | ||
__azurite_db*__.json | ||
__blobstorage__ | ||
__queuestorage__ | ||
local.settings.json | ||
test | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,10 @@ Thumbs.db | |
*.avi | ||
*.flv | ||
*.mov | ||
*.wmv | ||
*.wmv | ||
.python_packages | ||
__pycache__ | ||
venv | ||
|
||
VS Code | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"scriptFile": "main.py", | ||
"bindings": [ | ||
{ | ||
"authLevel": "admin", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"methods": [ | ||
"get", | ||
"post", | ||
"put", | ||
"patch", | ||
"delete" | ||
], | ||
"route": "{*route}" | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "$return" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,16 @@ | ||
import azure.functions as func | ||
from fastapi import FastAPI | ||
from pydantic import BaseModel | ||
|
||
app = FastAPI() | ||
|
||
from app.routers import users | ||
|
||
class Item(BaseModel): | ||
id: int | ||
name: str | ||
app = FastAPI() | ||
app.include_router(users.router, prefix='/users', tags=['Users']) | ||
|
||
|
||
@app.get("/") | ||
def root(): | ||
return {"message": "API health at 100%."} | ||
|
||
|
||
@app.get("/items") | ||
def get_items(): | ||
return {"message": f"{len([])} Items retrieved."} | ||
|
||
|
||
@app.get("/items/{itemId}") | ||
def get_item(item_id: int): | ||
return {"message": f"[id={item_id}] Item retrieved."} | ||
|
||
|
||
@app.post("/items") | ||
def add_item(item: Item): | ||
return {"message": f"[id={item.id}] New item '{item.name}' added."} | ||
async def health(): | ||
return {"message": "The API is 100% ready."} | ||
|
||
|
||
@app.delete("/items/{itemId}") | ||
def delete_item(item_id: int): | ||
return {"message": f"[id={item_id}] Item deleted."} | ||
async def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: | ||
return await func.AsgiMiddleware(app).handle_async(req, context) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import logging | ||
|
||
from fastapi import APIRouter | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/{user_id}") | ||
async def get_user(user_id: int): | ||
logging.info("Retrieving user \'%s\'...", user_id) | ||
return { | ||
"user_id": user_id, | ||
"username": 'vic', | ||
"firstname": 'Victor', | ||
"lastname": 'Magtanggol', | ||
} | ||
|
||
|
||
@router.put("/{user_id}") | ||
async def update_user(user_id: int): | ||
logging.info("Updating user \'%s\'...", user_id) | ||
return { | ||
"user_id": user_id, | ||
"username": 'vic', | ||
"firstname": 'Victor', | ||
"lastname": 'Magtanggol', | ||
} | ||
|
||
|
||
@router.delete("/{user_id}") | ||
async def delete_user(user_id: int): | ||
logging.info("Deleting user \'%s\'...", user_id) | ||
return {"message": "OK"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
} | ||
} | ||
}, | ||
"extensionBundle": { | ||
"id": "Microsoft.Azure.Functions.ExtensionBundle", | ||
"version": "[4.*, 5.0.0)" | ||
}, | ||
"extensions": { | ||
"http": { | ||
"routePrefix": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "", | ||
"FUNCTIONS_WORKER_RUNTIME": "python", | ||
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
azure-functions | ||
fastapi==0.111.0 | ||
fastapi==0.111.0 | ||
uvicorn==0.30.1 |
Empty file.