feat: complete secure pricing delivery and rollback documentation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from flask import Flask, jsonify
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return jsonify({"status": "healthy"}), 200
|
||||
|
||||
|
||||
@app.get("/pricing")
|
||||
def pricing():
|
||||
return jsonify({
|
||||
"service": "Startup Pricing Service",
|
||||
"version": "v1",
|
||||
"plans": [
|
||||
{"name": "Basic", "price": 10},
|
||||
{"name": "Pro", "price": 25},
|
||||
{"name": "Enterprise", "price": 50}
|
||||
]
|
||||
}), 200
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
@@ -0,0 +1,7 @@
|
||||
.venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.pytest_cache/
|
||||
.git/
|
||||
.env
|
||||
.gitignore
|
||||
@@ -0,0 +1,19 @@
|
||||
FROM python:3.13-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY app.py .
|
||||
|
||||
RUN useradd --create-home appuser
|
||||
USER appuser
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["python", "app.py"]
|
||||
@@ -0,0 +1,20 @@
|
||||
FROM python:3.13-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
COPY requirements-production.txt .
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements-production.txt
|
||||
|
||||
RUN useradd --create-home appuser
|
||||
|
||||
COPY --chown=appuser:appuser app.py .
|
||||
|
||||
USER appuser
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["gunicorn", "--workers", "2", "--bind", "0.0.0.0:5000", "app:app"]
|
||||
@@ -0,0 +1,26 @@
|
||||
from flask import Flask, jsonify
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return jsonify({"status": "healthy", "version": "v2"}), 200
|
||||
|
||||
|
||||
@app.get("/pricing")
|
||||
def pricing():
|
||||
return jsonify({
|
||||
"service": "Startup Pricing Service",
|
||||
"version": "v2",
|
||||
"plans": [
|
||||
{"name": "Starter", "price": 5},
|
||||
{"name": "Basic", "price": 12},
|
||||
{"name": "Pro", "price": 30},
|
||||
{"name": "Enterprise", "price": 60}
|
||||
]
|
||||
}), 200
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
@@ -0,0 +1,2 @@
|
||||
Flask>=3.1,<4.0
|
||||
gunicorn>=23,<24
|
||||
@@ -0,0 +1 @@
|
||||
Flask>=3.1,<4.0
|
||||
@@ -0,0 +1,32 @@
|
||||
import unittest
|
||||
from app import app
|
||||
|
||||
|
||||
class PricingServiceV2Tests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.client = app.test_client()
|
||||
|
||||
def test_health_endpoint(self):
|
||||
response = self.client.get("/health")
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
data = response.get_json()
|
||||
self.assertEqual(data["status"], "healthy")
|
||||
self.assertEqual(data["version"], "v2")
|
||||
|
||||
def test_pricing_endpoint(self):
|
||||
response = self.client.get("/pricing")
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
data = response.get_json()
|
||||
self.assertEqual(data["version"], "v2")
|
||||
self.assertEqual(len(data["plans"]), 4)
|
||||
self.assertEqual(data["plans"][0]["name"], "Starter")
|
||||
self.assertEqual(data["plans"][0]["price"], 5)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user