izuemon commited on
Commit
c8dac25
·
verified ·
1 Parent(s): ab40aff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -1
app.py CHANGED
@@ -482,7 +482,57 @@ def scratch_embed(project_id):
482
  os.unlink(tmp_path)
483
  except:
484
  pass
485
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
 
487
  if __name__ == "__main__":
488
  if os.environ.get("WERKZEUG_RUN_MAIN") != "true":
 
482
  os.unlink(tmp_path)
483
  except:
484
  pass
485
+
486
+ @app.route("/_proxy/R4", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"])
487
+ def proxy_r4():
488
+ query = request.query_string.decode()
489
+ target_url = "https://ci.line-apps.com/R4"
490
+ if query:
491
+ target_url += "?" + query
492
+
493
+ resp = requests.request(
494
+ method=request.method,
495
+ url=target_url,
496
+ headers=dict(request.headers),
497
+ data=None if request.method in ["GET", "HEAD"] else request.get_data(),
498
+ stream=True
499
+ )
500
+
501
+ return Response(
502
+ resp.raw,
503
+ status=resp.status_code,
504
+ headers={
505
+ **resp.headers,
506
+ "Access-Control-Allow-Origin": "*"
507
+ }
508
+ )
509
+
510
+ # ======================
511
+ # CHROME_GW Proxy
512
+ # ======================
513
+ @app.route("/_proxy/CHROME_GW/<path:path>", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"])
514
+ def proxy_chrome_gw(path):
515
+ query = request.query_string.decode()
516
+ target_url = f"https://line-chrome-gw.line-apps.com/{path}"
517
+ if query:
518
+ target_url += "?" + query
519
+
520
+ resp = requests.request(
521
+ method=request.method,
522
+ url=target_url,
523
+ headers=dict(request.headers),
524
+ data=None if request.method in ["GET", "HEAD"] else request.get_data(),
525
+ stream=True
526
+ )
527
+
528
+ return Response(
529
+ resp.raw,
530
+ status=resp.status_code,
531
+ headers={
532
+ **resp.headers,
533
+ "Access-Control-Allow-Origin": "*"
534
+ }
535
+ )
536
 
537
  if __name__ == "__main__":
538
  if os.environ.get("WERKZEUG_RUN_MAIN") != "true":