-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
80 lines (64 loc) · 1.9 KB
/
main.py
File metadata and controls
80 lines (64 loc) · 1.9 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import os
import json
import time
from flask import Flask, render_template, make_response, request
from flask_basicauth import BasicAuth
from lib.ai import ai
import config
from lib.database import featurebase_tables_schema
# slothbot services app
app = Flask(__name__)
app.config['BASIC_AUTH_USERNAME'] = config.basic_auth_username
app.config['BASIC_AUTH_PASSWORD'] = config.basic_auth_password
# add basic auth to endpoints
basic_auth = BasicAuth(app)
@app.route('/help', methods=['POST'])
@basic_auth.required
def help():
document = request.json
document = ai("help", document)
return make_response(document)
@app.route('/dream', methods=['POST'])
@basic_auth.required
def dream():
document = request.json
ai("dream", document)
return make_response(document)
@app.route('/docs', methods=['POST'])
@basic_auth.required
def docs():
document = request.json
# update document with AI inference
ai("docs", document)
return make_response(document)
@app.route('/query', methods=['POST'])
@basic_auth.required
def query():
document = request.json
return make_response(document)
@app.route('/status', methods=['POST'])
@basic_auth.required
def status():
document = request.json
return make_response(document)
@app.route('/graph', methods=['POST'])
@basic_auth.required
def graph():
document = request.json
document['answer'] = "I would generate a graph from SQL."
return make_response(document)
@app.route('/log', methods=['POST'])
@basic_auth.required
def log():
document = request.json
return make_response(document)
@app.route('/feedback', methods=['POST'])
@basic_auth.required
def feedback():
document = request.json
return make_response(document)
if __name__ == '__main__':
# This is used when running locally.
# app.run(host='127.0.0.1', port=8000, debug=True)
app.run(host='localhost', port=8000, debug=True)
dev = True