-
Notifications
You must be signed in to change notification settings - Fork 11
/
app.py
37 lines (26 loc) · 902 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
29
30
31
32
33
34
35
36
37
from flask import Flask, jsonify, render_template, request
from gpt import GPTStructuredReporting
app = Flask(__name__)
# Global variable to store the API key
api_key = None
@app.route("/")
def index():
return render_template("index.html")
@app.route("/reports")
def reports():
return render_template("reports.html")
@app.route("/process", methods=["POST"])
def process():
report = request.form["report"]
api_key = request.form["api_key"]
if report == "test":
response = jsonify({"test": "yes"})
response.headers["Content-Type"] = "application/json"
return response
gpt = GPTStructuredReporting(api_key, "static/report_templates.json")
structured_report = gpt(report)
response = jsonify(structured_report)
response.headers["Content-Type"] = "application/json"
return response
if __name__ == "__main__":
app.run(debug=True)