David Ko commited on
Commit
913f3b4
ยท
1 Parent(s): a44b826

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +8 -10
api.py CHANGED
@@ -1150,11 +1150,11 @@ def login():
1150
 
1151
  # ๋ฆฌ๋””๋ ‰์…˜ ์ฒ˜๋ฆฌ
1152
  next_page = request.args.get('next')
1153
- if next_page and next_page.startswith('/'):
1154
  print(f"Redirecting to: {next_page}")
1155
  return redirect(next_page)
1156
- print("Redirecting to index page")
1157
- return redirect('/index')
1158
  else:
1159
  error = 'Invalid username or password'
1160
  print(f"Login failed: {error}")
@@ -1209,19 +1209,17 @@ def status():
1209
  })
1210
 
1211
  @app.route('/')
 
1212
  def index():
1213
  print(f"Root route accessed, user authenticated: {current_user.is_authenticated}")
1214
- if current_user.is_authenticated:
1215
- print(f"User is authenticated as: {current_user.id}")
1216
- return redirect('/index')
1217
- else:
1218
- print("User is not authenticated, redirecting to login")
1219
- return redirect(url_for('login'))
1220
 
1221
  @app.route('/index')
1222
  @login_required
1223
  def index_page():
1224
- return send_from_directory('static', 'index.html')
 
 
1225
 
1226
  if __name__ == "__main__":
1227
  # ํ—ˆ๊น…ํŽ˜์ด์Šค Space์—์„œ๋Š” PORT ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค
 
1150
 
1151
  # ๋ฆฌ๋””๋ ‰์…˜ ์ฒ˜๋ฆฌ
1152
  next_page = request.args.get('next')
1153
+ if next_page and next_page.startswith('/') and next_page != '/login':
1154
  print(f"Redirecting to: {next_page}")
1155
  return redirect(next_page)
1156
+ print("Redirecting to root page")
1157
+ return redirect('/')
1158
  else:
1159
  error = 'Invalid username or password'
1160
  print(f"Login failed: {error}")
 
1209
  })
1210
 
1211
  @app.route('/')
1212
+ @login_required
1213
  def index():
1214
  print(f"Root route accessed, user authenticated: {current_user.is_authenticated}")
1215
+ return send_from_directory('static', 'index.html')
 
 
 
 
 
1216
 
1217
  @app.route('/index')
1218
  @login_required
1219
  def index_page():
1220
+ # /index ๊ฒฝ๋กœ๋„ ๋ฃจํŠธ ๊ฒฝ๋กœ์™€ ๋™์ผํ•˜๊ฒŒ ์ฒ˜๋ฆฌ
1221
+ print("Index route redirecting to root")
1222
+ return redirect('/')
1223
 
1224
  if __name__ == "__main__":
1225
  # ํ—ˆ๊น…ํŽ˜์ด์Šค Space์—์„œ๋Š” PORT ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค