Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

 api.py

View raw Download
text/x-script.python • 1.19 kiB
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
@api_app.route("/user/<username>", methods=["GET"])
41
def get_user(username):
42
response = flask.make_response(flask.render_template("user.xml", user=db.session.get(User, username)))
43
response.headers["Content-Type"] = "application/xml"
44
return response
45
46
47
app.register_blueprint(api_app)
48