Use Uvicorn for production with Nginx

This commit is contained in:
2022-10-12 07:22:22 +01:00
parent 966fa37fe8
commit ce551bde75
7 changed files with 104 additions and 18 deletions

View File

@@ -0,0 +1,22 @@
{
const data = document.currentScript.dataset;
const isDebug = data.debug === "True";
if (isDebug) {
document.addEventListener("htmx:beforeOnLoad", function (event) {
const xhr = event.detail.xhr;
if (xhr.status == 500 || xhr.status == 404) {
// Tell htmx to stop processing this response
event.stopPropagation();
document.children[0].innerHTML = xhr.response;
// Run Djangos inline script
// (1, eval) wtf - see https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript
(1, eval)(document.scripts[0].innerText);
// Need to directly call Djangos onload function since browser wont
window.onload();
}
});
}
}

View File

@@ -1,4 +1,5 @@
import logging
from asyncio import sleep
import stripe
from django.conf import settings
@@ -21,7 +22,8 @@ logger = logging.getLogger(__name__)
class Home(View):
template_name = "index.html"
def get(self, request):
async def get(self, request):
# await sleep(1)
return render(request, self.template_name)