sethmcknight commited on
Commit
e3e3a84
·
1 Parent(s): 2d9ce15

Implement initial Flask application with health check endpoint, basic HTML template, and styling; add unit tests for endpoints

Browse files
Files changed (5) hide show
  1. app.py +20 -0
  2. project-plan.md +3 -3
  3. static/style.css +54 -0
  4. templates/index.html +27 -0
  5. tests/test_app.py +27 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, jsonify, render_template
2
+
3
+ app = Flask(__name__)
4
+
5
+ @app.route("/")
6
+ def index():
7
+ """
8
+ Renders the main page.
9
+ """
10
+ return render_template("index.html")
11
+
12
+ @app.route("/health")
13
+ def health():
14
+ """
15
+ Health check endpoint.
16
+ """
17
+ return jsonify({"status": "ok"}), 200
18
+
19
+ if __name__ == "__main__":
20
+ app.run(debug=True)
project-plan.md CHANGED
@@ -15,9 +15,9 @@ This plan outlines the steps to design, build, and deploy a Retrieval-Augmented
15
 
16
  ## 2. "Hello World" Deployment
17
 
18
- - [ ] **Minimal App:** Develop a minimal Flask application (`app.py`) with a `/health` endpoint that returns a JSON status object.
19
- - [ ] **Unit Test:** Write a test for the `/health` endpoint to ensure it returns a `200 OK` status and the correct JSON payload.
20
- - [ ] **Local Validation:** Run the app and tests locally to confirm everything works.
21
 
22
  ## 3. CI/CD and Initial Deployment
23
 
 
15
 
16
  ## 2. "Hello World" Deployment
17
 
18
+ - [x] **Minimal App:** Develop a minimal Flask application (`app.py`) with a `/health` endpoint that returns a JSON status object.
19
+ - [x] **Unit Test:** Write a test for the `/health` endpoint to ensure it returns a `200 OK` status and the correct JSON payload.
20
+ - [x] **Local Validation:** Run the app and tests locally to confirm everything works.
21
 
22
  ## 3. CI/CD and Initial Deployment
23
 
static/style.css ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: 'Inter', sans-serif;
3
+ background-color: #f0f2f5;
4
+ color: #333;
5
+ margin: 0;
6
+ display: flex;
7
+ justify-content: center;
8
+ align-items: center;
9
+ min-height: 100vh;
10
+ text-align: center;
11
+ }
12
+
13
+ .container {
14
+ max-width: 600px;
15
+ padding: 40px;
16
+ background-color: #fff;
17
+ border-radius: 16px;
18
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
19
+ }
20
+
21
+ header h1 {
22
+ font-size: 48px;
23
+ font-weight: 700;
24
+ color: #1a73e8;
25
+ margin: 0;
26
+ }
27
+
28
+ .subtitle {
29
+ font-size: 18px;
30
+ color: #5f6368;
31
+ margin-top: 8px;
32
+ }
33
+
34
+ .coming-soon {
35
+ margin-top: 40px;
36
+ }
37
+
38
+ .coming-soon h2 {
39
+ font-size: 28px;
40
+ font-weight: 600;
41
+ color: #3c4043;
42
+ }
43
+
44
+ .coming-soon p {
45
+ font-size: 16px;
46
+ line-height: 1.6;
47
+ color: #5f6368;
48
+ }
49
+
50
+ footer {
51
+ margin-top: 40px;
52
+ font-size: 12px;
53
+ color: #9aa0a6;
54
+ }
templates/index.html ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PolicyWise</title>
7
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
9
+ </head>
10
+ <body>
11
+ <div class="container">
12
+ <header>
13
+ <h1>PolicyWise</h1>
14
+ <p class="subtitle">Your Intelligent Policy Assistant</p>
15
+ </header>
16
+ <main>
17
+ <div class="coming-soon">
18
+ <h2>Coming Soon</h2>
19
+ <p>We're putting the finishing touches on our revolutionary RAG-powered chatbot. Get ready to have your policy questions answered instantly.</p>
20
+ </div>
21
+ </main>
22
+ <footer>
23
+ <p>&copy; 2025 MSSE AI Engineering Project</p>
24
+ </footer>
25
+ </div>
26
+ </body>
27
+ </html>
tests/test_app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from app import app as flask_app
3
+
4
+ @pytest.fixture
5
+ def app():
6
+ yield flask_app
7
+
8
+ @pytest.fixture
9
+ def client(app):
10
+ return app.test_client()
11
+
12
+ def test_health_endpoint(client):
13
+ """
14
+ Tests the /health endpoint.
15
+ """
16
+ response = client.get("/health")
17
+ assert response.status_code == 200
18
+ assert response.json == {"status": "ok"}
19
+
20
+ def test_index_endpoint(client):
21
+ """
22
+ Tests the / endpoint.
23
+ """
24
+ response = client.get("/")
25
+ assert response.status_code == 200
26
+ assert b"PolicyWise" in response.data
27
+ assert b"Coming Soon" in response.data