mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-05 06:20:10 +01:00
c4eb46ca19
* implement dnd uploader show file upload progress write files to hotdirector build simple flaskAPI to process files one off * move document processor calls to util build out dockerfile to run both procs at the same time update UI to check for document processor before upload * disable pragma update on boot * dockerfile changes * add filetype restrictions based on python app support response and show rejected files in the UI * cleanup * stub migrations on boot to prevent exit condition * update CF template for AWS deploy
21 lines
820 B
Python
21 lines
820 B
Python
from flask import Flask, json, request
|
|
from scripts.watch.process_single import process_single
|
|
from scripts.watch.filetypes import ACCEPTED_MIMES
|
|
api = Flask(__name__)
|
|
|
|
WATCH_DIRECTORY = "hotdir"
|
|
@api.route('/process', methods=['POST'])
|
|
def process_file():
|
|
content = request.json
|
|
target_filename = content.get('filename')
|
|
print(f"Processing {target_filename}")
|
|
success, reason = process_single(WATCH_DIRECTORY, target_filename)
|
|
return json.dumps({'filename': target_filename, 'success': success, 'reason': reason})
|
|
|
|
@api.route('/accepts', methods=['GET'])
|
|
def get_accepted_filetypes():
|
|
return json.dumps(ACCEPTED_MIMES)
|
|
|
|
@api.route('/', methods=['GET'])
|
|
def root():
|
|
return "<p>Use POST /process with filename key in JSON body in order to process a file. File by that name must exist in hotdir already.</p>" |