-
Notifications
You must be signed in to change notification settings - Fork 223
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
Showing
8 changed files
with
95 additions
and
42 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,3 @@ | ||
FROM tiangolo/uwsgi-nginx-flask:python3.6-alpine3.7 | ||
COPY templates /app/templates | ||
COPY app.py /app/main.py |
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,13 @@ | ||
.phony: build push | ||
|
||
all: build push | ||
#CMD := $(shell aws ecr get-login --no-include-email --region us-east-1) | ||
|
||
build: | ||
docker build -t vallard/eksdynamo . | ||
|
||
push: | ||
#${CMD} | ||
docker tag vallard/eksdynamo:latest | ||
docker push | ||
|
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,28 @@ | ||
#!/usr/bin/env python | ||
from flask import Flask, render_template | ||
import os | ||
import boto3 # required for getting AWS resources | ||
import botocore | ||
|
||
dynamodb = boto3.resource('dynamodb') # dynamo client | ||
app = Flask(__name__) | ||
@app.route('/') | ||
def index(): | ||
|
||
table = dynamodb.Table(os.getenv('DYNAMODB_TABLE', 'dynamoUsers')) | ||
results = [] | ||
error = "" | ||
try: | ||
results = table.scan() | ||
except botocore.exceptions.ClientError as e: | ||
error = str(e) | ||
print("client error: ", e) | ||
pass | ||
|
||
print(results) | ||
return render_template('index.html', | ||
error = error, | ||
items = results['Items']) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug = True) |
51 changes: 51 additions & 0 deletions
51
segment07-integrations/dynamo-example/templates/index.html
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,51 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> | ||
|
||
<title>Dynamo Kubernetes Example</title> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-light bg-light"> | ||
<span class="navbar-brand mb-0 h1">Dynamo - Kubernetes on AWS</span> | ||
</nav> | ||
<div class="container"> | ||
{% if error != "" %} | ||
<div class="alert alert-danger" role="alert"> | ||
{{ error }} | ||
</div> | ||
{% endif %} | ||
<h1 class="display-1">Users</h1> | ||
<p class="lead">These are the entries in our users table</p> | ||
<table class=table> | ||
<thead> | ||
<tr> | ||
<th scope="col">ID</th> | ||
<th scope="col">Name</th> | ||
<th scope="col">Email</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for item in items %} | ||
<tr> | ||
<td>{{ item['id'] }}</td> | ||
<td>{{ item['name'] }}</td> | ||
<td>{{ item['email'] }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<!-- Optional JavaScript --> | ||
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | ||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
Empty file.
Binary file removed
BIN
-1.28 KB
segment07-integrations/dynamo/dynamo/__pycache__/Dynamo.cpython-37.pyc
Binary file not shown.
Binary file removed
BIN
-144 Bytes
segment07-integrations/dynamo/dynamo/__pycache__/__init__.cpython-37.pyc
Binary file not shown.