dinhquangson commited on
Commit
fe8dc94
1 Parent(s): 4e88ee4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -2,6 +2,7 @@ from fastapi import FastAPI, UploadFile, File
2
  from fastapi.middleware.cors import CORSMiddleware
3
  # Loading
4
  import os
 
5
  from os import makedirs,getcwd
6
  from os.path import join,exists,dirname
7
  from datasets import load_dataset
@@ -71,9 +72,13 @@ def generate_embeddings(dataset, batch_size=32):
71
 
72
  @app.post("/uploadfile/")
73
  async def create_upload_file(file: UploadFile = File(...)):
 
 
 
 
74
  # Here you can save the file and do other operations as needed
75
  full_dataset = load_dataset("parquet",
76
- data_files=FILEPATH_PATTERN,
77
  split="train",
78
  cache_dir=temp_path,
79
  keep_in_memory=True,
 
2
  from fastapi.middleware.cors import CORSMiddleware
3
  # Loading
4
  import os
5
+ import shutil
6
  from os import makedirs,getcwd
7
  from os.path import join,exists,dirname
8
  from datasets import load_dataset
 
72
 
73
  @app.post("/uploadfile/")
74
  async def create_upload_file(file: UploadFile = File(...)):
75
+ file_savePath = join(temp_path,file.filename)
76
+
77
+ with open(file_savePath,'wb') as f:
78
+ shutil.copyfileobj(file.file, f)
79
  # Here you can save the file and do other operations as needed
80
  full_dataset = load_dataset("parquet",
81
+ data_files=file_savePath,
82
  split="train",
83
  cache_dir=temp_path,
84
  keep_in_memory=True,