Forums

Automating "git pull" , from a github repo using flask by adding webhook

I have followed each steps from the article "https://medium.com/@aadibajpai/deploying-to-pythonanywhere-via-github-6f967956e664" , here he has explain how to add webhook and automate the push event . Like if there is a push in the repository the file will reflect in pythonanywhere . here is the flask code

@app.route('/update_server', methods=['POST'])
def webhook():
    if request.method == 'POST':
        repo = git.Repo('path/to/git_repo')
        origin = repo.remotes.origin
        origin.pull()
        return 'Updated PythonAnywhere successfully', 200
     else:
        return 'Wrong event type', 400

What is happening it is pulling everything , but how can i pull only the master branch ?? i don't want the branches to be pulled?

You need to check the GitHub webhooks and/or git module docs on how to confirgure the request.