from insert_into_milvus_db import (TextVectorizer, get_secrets, create_schema, upsert_db) from flask import Flask, Response from flask_cors import cross_origin, CORS import logging app = Flask(__name__) CORS(app) logging.info('Initiated') vectorizer = TextVectorizer(checkpoint='all-mpnet-base-v2') uri, token, collection_name = get_secrets() collection = create_schema(uri, token, collection_name) @app.route("/") @cross_origin() def update_news_in_db(): status_json = "{'status':'success'}" status_code = 200 try: upsert_db(vectorizer, collection) except: status_json = "{'status':'failure'}" status_code = 500 return Response(status_json, status=status_code, mimetype='application/json') if __name__ == "__main__": app.run(host="0.0.0.0", port=7860, timeout=120, workers=1, threads=1)