api.py
Python script, ASCII text executable
1import uuid 2from models import * 3from app import app, db, bcrypt 4from misc_utils import * 5from common import git_command 6import os 7import shutil 8import config 9import flask 10import git 11import subprocess 12from flask_httpauth import HTTPBasicAuth 13import zlib 14import re 15import datetime 16 17auth = HTTPBasicAuth(realm=config.AUTH_REALM + " Data API") 18 19api_app = flask.Blueprint("api_app", __name__, template_folder="templates/api/", url_prefix="/data-api/") 20 21 22@auth.verify_password 23def verify_password(username, password): 24user = User.query.filter_by(username=username).first() 25 26if user and bcrypt.check_password_hash(user.password_hashed, password): 27flask.g.user = username 28return True 29 30return False 31 32 33@api_app.route("/", methods=["GET"]) 34def welcome(): 35response = flask.make_response(flask.render_template("welcome.xml")) 36response.headers["Content-Type"] = "application/xml" 37return response 38 39 40app.register_blueprint(api_app) 41