Fix connections
This commit is contained in:
@@ -72,18 +72,20 @@ def upload_file(filename: str, key: str, bucket: str):
|
||||
|
||||
|
||||
def pika_callback(ch, method, properties, body):
|
||||
data = json.loads(body)
|
||||
params = data['params']
|
||||
url = data['url']
|
||||
files = []
|
||||
for file in params['files']:
|
||||
fn = os.path.join(gettempdir(), uuid4().hex)
|
||||
download_file(file['name'], file['bucket'], fn)
|
||||
files.append(fn)
|
||||
proxy = ServerProxy(url)
|
||||
proxy.send(params, files, Config.ret_path)
|
||||
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
try:
|
||||
data = json.loads(body)
|
||||
params = data['params']
|
||||
url = data['url']
|
||||
files = []
|
||||
for file in data['files']:
|
||||
fn = os.path.join(gettempdir(), uuid4().hex)
|
||||
download_file(file['url']['name'], file['url']['bucket'], fn)
|
||||
file['url'] = fn
|
||||
files.append(file)
|
||||
proxy = ServerProxy(url)
|
||||
proxy.send(params, files, Config.ret_path)
|
||||
finally:
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
|
||||
|
||||
def pika_task():
|
||||
@@ -173,8 +175,9 @@ def accept(params, files, url):
|
||||
files_s3 = []
|
||||
for file in params['files']:
|
||||
fn = uuid4().hex
|
||||
upload_file(file, fn, Config.s3_bucket)
|
||||
files_s3.append({'name': fn, 'bucket': Config.s3_bucket})
|
||||
upload_file(file['url'], fn, Config.s3_bucket)
|
||||
file['url'] = {'name': fn, 'bucket': Config.s3_bucket}
|
||||
files_s3.append(file)
|
||||
data = {
|
||||
'params': params,
|
||||
'files': files_s3,
|
||||
@@ -221,7 +224,7 @@ def xmlrpc_task():
|
||||
|
||||
app = FastAPI()
|
||||
app.add_middleware(CORSMiddleware,
|
||||
allow_origins=['http://10.10.8.24:3000'],
|
||||
allow_origins=['http://10.10.8.79:3000'],
|
||||
allow_credentials=True,
|
||||
allow_methods=['*'],
|
||||
allow_headers=['*']
|
||||
|
||||
Reference in New Issue
Block a user