Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from os.path import exists
from os import stat, remove, makedirs, environ
from time import strftime, time, localtime
from urllib.parse import urlparse

import graphyte
import requests
Expand Down Expand Up @@ -131,6 +132,12 @@ def client_ip():
return request.headers.get('X-Forwarded-For', request.remote_addr)


def request_hostname():
"""Returns the hostname of the request.
"""
return urlparse(request.base_url).hostname


def error(message, code=400, **kwargs):
"""Return a structured JSON error message.
"""
Expand Down Expand Up @@ -251,9 +258,18 @@ def kle_to_qmk(kle):
def root():
"""Serve up the documentation for this API.
"""
if request_hostname() == 'install.qmk.fm':
return redirect('https://raw.githubusercontent.com/qmk/qmk_firmware/refs/heads/bootstrap/util/env-bootstrap.sh')
return redirect('https://docs.qmk.fm/#/api_docs')


@app.route('/install.sh', methods=['GET'])
def install():
"""Serve up the install script for the QMK CLI.
"""
return redirect('https://raw.githubusercontent.com/qmk/qmk_firmware/refs/heads/bootstrap/util/env-bootstrap.sh')


@app.route('/v1', methods=['GET'])
def GET_v1():
"""Return the API's status.
Expand Down