test user id in session
Browse files
app.py
CHANGED
|
@@ -31,8 +31,8 @@ if not os.path.exists(OUT_FOLDER):
|
|
| 31 |
|
| 32 |
@app.route('/', methods=['GET', 'POST'])
|
| 33 |
def index():
|
| 34 |
-
user_id = session.get('_id')
|
| 35 |
-
|
| 36 |
if user_id is None:
|
| 37 |
user_id = uuid.uuid4()
|
| 38 |
session['_id'] = user_id
|
|
@@ -40,6 +40,7 @@ def index():
|
|
| 40 |
file_path = os.path.join(OUT_FOLDER, f'{user_id}.csv')
|
| 41 |
with open(file_path, 'w') as f:
|
| 42 |
f.write("image,id,name,xMin,xMax,yMin,yMax\n")
|
|
|
|
| 43 |
|
| 44 |
if request.method == 'POST':
|
| 45 |
if 'file' not in request.files:
|
|
@@ -123,10 +124,11 @@ def label(id):
|
|
| 123 |
|
| 124 |
@app.route('/image/<f>')
|
| 125 |
def images(f):
|
| 126 |
-
user_id = session.get('_id')
|
| 127 |
-
|
| 128 |
# images = app.config["IMAGES"] + f'/{user_id}'
|
| 129 |
img_path = os.path.join(UPLOAD_FOLDER, f'{user_id}/{f}')
|
|
|
|
| 130 |
# print(images, '/', f)
|
| 131 |
# return send_file(images +'/'+f)
|
| 132 |
return send_file(img_path)
|
|
|
|
| 31 |
|
| 32 |
@app.route('/', methods=['GET', 'POST'])
|
| 33 |
def index():
|
| 34 |
+
# user_id = session.get('_id')
|
| 35 |
+
user_id = request.cookies.get('session')
|
| 36 |
if user_id is None:
|
| 37 |
user_id = uuid.uuid4()
|
| 38 |
session['_id'] = user_id
|
|
|
|
| 40 |
file_path = os.path.join(OUT_FOLDER, f'{user_id}.csv')
|
| 41 |
with open(file_path, 'w') as f:
|
| 42 |
f.write("image,id,name,xMin,xMax,yMin,yMax\n")
|
| 43 |
+
print(user_id)
|
| 44 |
|
| 45 |
if request.method == 'POST':
|
| 46 |
if 'file' not in request.files:
|
|
|
|
| 124 |
|
| 125 |
@app.route('/image/<f>')
|
| 126 |
def images(f):
|
| 127 |
+
#user_id = session.get('_id')
|
| 128 |
+
user_id = request.cookies.get('session')
|
| 129 |
# images = app.config["IMAGES"] + f'/{user_id}'
|
| 130 |
img_path = os.path.join(UPLOAD_FOLDER, f'{user_id}/{f}')
|
| 131 |
+
print(img_path)
|
| 132 |
# print(images, '/', f)
|
| 133 |
# return send_file(images +'/'+f)
|
| 134 |
return send_file(img_path)
|