Auth version of remote git pull script

Username and password admin/go123456, change in code.

from flask import Flask
import subprocess
app = Flask(__name__)
import os
from functools import wraps
from flask import request, Response

def check_auth(username, password):
    return username == 'admin' and password == 'go123456'

def authenticate():
    return Response(
    'Wrong credentials,
    {'WWW-Authenticate': 'Basic realm="Login Required"'})

def requires_auth(f):
    def decorated(*args, **kwargs):
        auth = request.authorization
        if not auth or not check_auth(auth.username, auth.password):
            return authenticate()
        return f(*args, **kwargs)
    return decorated

def main():
        output = subprocess.check_output(["git", "pull"])
        return output
    except subprocess.CalledProcessError as exc:
        return "Status : FAIL errcode: {}, output: {}".format(exc.returncode, exc.output)"", port=int("8080"))
#flask #git
Ivan Borshchov profile picture
May 05, 2017
by Ivan Borshchov
Did it help you?
Yes !

Best related