forked from ibm-developer-skills-network/DevSecOps-HTTP-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
28 lines (21 loc) · 702 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from flask import Flask, jsonify
from flask_cors import CORS
from flask_talisman import Talisman
from post_factory import PostFactory
app = Flask(__name__)
csp = {
'default-src': '\'self\''
}
# talisman = Talisman(app, content_security_policy=csp)
# Enable Cross Origin Resource Sourcing (CORS) policies
CORS(app, resources={"/*": {"origins": "http://localhost:3000"}})
@app.route("/")
def index():
"""Root URL response"""
app.logger.info("Request for Root URL")
return (jsonify(name="Data Retrieval Service", version="1.0"), 200)
@app.route("/posts", methods=["GET"])
def get_data():
"""Returns forum post data"""
data = PostFactory.generate(5)
return jsonify(data)