Skip to content

Commit c1ac7e5

Browse files
committed
add monitoring app
1 parent 901da90 commit c1ac7e5

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ ENV/
8989
.ropeproject
9090

9191
*.swp
92+
93+
monitor-flask-apps/.env

monitor-flask-apps/app.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
import re
3+
import rollbar
4+
from flask import Flask, render_template
5+
from werkzeug.exceptions import NotFound
6+
7+
8+
app = Flask(__name__)
9+
rollbar.init(os.environ.get('ROLLBAR_SECRET'))
10+
rollbar.report_message('Rollbar is configured correctly')
11+
12+
MIN_PAGE_NAME_LENGTH = 2
13+
14+
15+
@app.route("/<string:page>/")
16+
def show_page(page):
17+
valid_length = len(page) >= MIN_PAGE_NAME_LENGTH
18+
valid_name = re.match('^[a-z]+$', page.lower()) is not None
19+
if valid_length and valid_name:
20+
return render_template("{}.html".format(page))
21+
else:
22+
msg = "Sorry, couldn't find page with name {}".format(page)
23+
raise NotFound(msg)
24+
25+
26+
if __name__ == "__main__":
27+
app.run(debug=True)

monitor-flask-apps/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask==0.12.2
2+
rollbar==0.13.12

monitor-flask-apps/template.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Rollbar token, found in project settings
2+
export ROLLBAR_SECRET=''
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>You found the Battlegrounds GIF!</title>
5+
</head>
6+
<body>
7+
<h1>PUBG so good.</h1>
8+
<img src="https://media.giphy.com/media/3ohzdLMlhId2rJuLUQ/giphy.gif">
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)