Created
October 15, 2019 18:55
-
-
Save grangerp/cc8f4d095025d436b692e42674274909 to your computer and use it in GitHub Desktop.
single file django app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import html | |
import os | |
import sys | |
from django.conf import settings | |
from django.core.wsgi import get_wsgi_application | |
from django.http import HttpResponse, HttpResponseRedirect | |
from django.urls import path | |
from django.utils.crypto import get_random_string | |
settings.configure( | |
DEBUG=(os.getenv("DEBUG", "") == "1"), | |
ALLOWED_HOSTS=["*"], # Disable host header validation | |
ROOT_URLCONF=__name__, # Make this module the urlconf | |
SECRET_KEY=get_random_string( | |
50 | |
), # We aren't using any security features but Django requires this setting | |
) | |
ACCESS_TOKEN = "test" | |
def authorize(request, tenant_id): | |
redirect_to = request.GET.get("redirect_uri") | |
return HttpResponseRedirect(f"{redirect_to}#access_token={ACCESS_TOKEN}") | |
urlpatterns = [path("<str:tenant_id>/oauth2/v2.0/authorize", authorize)] | |
app = get_wsgi_application() | |
def main(): | |
from django.core.management import execute_from_command_line | |
execute_from_command_line(sys.argv) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment