By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 api.py

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