From fae6bc918494a90a6f93091bdcbe1d4d875e60c0 Mon Sep 17 00:00:00 2001 From: wvffle Date: Sat, 2 Jul 2022 00:41:38 +0000 Subject: [PATCH] Fix logging in in prebuilds --- .gitpod.yml | 2 +- .gitpod/init_actor.py | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 83af2a3c6..d37e65d04 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -34,7 +34,7 @@ tasks: # Login with cURL to create actors docker-compose up -d nginx gp ports await 8000 - sleep 20 # allow django to start + sleep 10 python .gitpod/init_actor.py # Import music diff --git a/.gitpod/init_actor.py b/.gitpod/init_actor.py index 7d011c17d..72e3a97e8 100644 --- a/.gitpod/init_actor.py +++ b/.gitpod/init_actor.py @@ -1,20 +1,17 @@ -import subprocess import requests -INSTANCE_URL = subprocess.check_output(['gp', 'url', '8000']).decode()[:-1] - # Login to initialize user actor req = requests.Session() -res = req.get(INSTANCE_URL + '/login') +res = req.get('http://localhost:8000/login') token = res.cookies['csrftoken'] -req.post(INSTANCE_URL + '/api/v1/users/login', data={ +req.post('http://localhost:8000/api/v1/users/login', data={ 'username': 'gitpod', 'password': 'gitpod' }, headers={ - 'Referer': INSTANCE_URL + '/login', + 'Referer': 'http://localhost:8000/login', 'X-CSRFTOKEN': token }) -req.get(INSTANCE_URL) \ No newline at end of file +req.get('http://localhost:8000') \ No newline at end of file