-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
36 lines (27 loc) · 858 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
from flask import Flask
from flask import jsonify
from flask import request
from services.typesense import TypeSense
app = Flask(__name__)
@app.route('/health', methods=['GET'])
def health():
healthy = {'success' : True}
return jsonify(healthy), 200
@app.route('/search/', methods=['POST'])
def search():
data = request.get_json()
search_params = data['search_params']
collection = data['collection']
print(search_params)
print(collection)
result = client.search(collection, search_params)
return jsonify(result), 200
@app.route('/create/collection', methods=['POST'])
def create_collection():
result = client.create_collection(schema)
return jsonify(result), 200
@app.route('/create/document', methods=['POST'])
def create_document():
if __name__ == '__main__':
client = TypeSense()
app.run()