Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b6fcf57

Browse files
sprinrazius
authored andcommitted
Use env var for path to repos.json
1 parent d7c0317 commit b6fcf57

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111

1212
app = Flask(__name__)
1313

14+
# The repos.json file should be readable by the user running the Flask app,
15+
# and the absolute path should be given by this environment variable.
16+
REPOS_JSON_PATH = os.environ['FLASK_GITHUB_WEBHOOK_REPOS_JSON']
17+
1418

1519
@app.route("/", methods=['GET', 'POST'])
1620
def index():
1721
# Store the IP address blocks that github uses for hook requests.
1822
hook_blocks = requests.get('https://api.github.com/meta').json()['hooks']
1923

2024
if request.method == 'GET':
21-
return ' Nothing to see here, move along ...'
25+
return ''
2226

2327
elif request.method == 'POST':
2428
# Check if the POST request if from github.com
@@ -34,7 +38,7 @@ def index():
3438
if request.headers.get('X-GitHub-Event') != "push":
3539
return json.dumps({'msg': "wrong event type"})
3640

37-
repos = json.loads(io.open('repos.json', 'r').read())
41+
repos = json.loads(io.open(REPOS_JSON_PATH, 'r').read())
3842

3943
payload = json.loads(request.data)
4044
repo_meta = {
File renamed without changes.

0 commit comments

Comments
 (0)