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