Skip to content

Instantly share code, notes, and snippets.

View a-toms's full-sized avatar
🌱
Ecstatic!

Tom a-toms

🌱
Ecstatic!
View GitHub Profile
@a-toms
a-toms / _sim_models_py_2_4_add_your_templates_0.txt
Created September 14, 2023 17:26
# sim/models.py - ## 2.4 Add your templates
html
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
<script src="https://unpkg.com/htmx.org"></script>
</head>
<body>
<h1>Welcome to the Mind Upload Dashboard</h1>
<button hx-post="/process-task/" hx-trigger="click" hx-swap="outerHTML">Initiate Mind Upload</button>
@a-toms
a-toms / _section_1_setup_your_django_app_1.txt
Created September 14, 2023 17:26
- ## Section 1: Setup your Django app
bash
django-admin startproject core .
python manage.py startapp sim
@a-toms
a-toms / _section_1_setup_your_django_app_0.txt
Created September 14, 2023 17:26
- ## Section 1: Setup your Django app
bash
pip install django requests
@a-toms
a-toms / #_section_4:_connect_your_serverless_function_to_your_django_app_-_code_block_7_6.txt
Created September 14, 2023 17:23
# Section 4: Connect your Serverless Function to your Django app - Code Block 7
cd sam-app
sam local start-api
@a-toms
a-toms / #_section_4:_connect_your_serverless_function_to_your_django_app_-_code_block_6_5.txt
Created September 14, 2023 17:23
# Section 4: Connect your Serverless Function to your Django app - Code Block 6
python manage.py runserver
@a-toms
a-toms / #_section_4:_connect_your_serverless_function_to_your_django_app_-_code_block_5_4.txt
Created September 14, 2023 17:23
# Section 4: Connect your Serverless Function to your Django app - Code Block 5
<!DOCTYPE html>
<html xmlns:hx-on="http://www.w3.org/1999/xhtml">
<head>
<title>Dashboard</title>
<script src="https://unpkg.com/htmx.org"></script>
</head>
<body>
<h1>Welcome to your Mind Uploader</h1>
@a-toms
a-toms / #_section_4:_connect_your_serverless_function_to_your_django_app_-_code_block_4_3.txt
Created September 14, 2023 17:23
# Section 4: Connect your Serverless Function to your Django app - Code Block 4
Event = {'body': {'task_id': 1}, 'httpMethod': 'POST'}
Received task_id 1
Completed task_id 1
END RequestId: ac4d9b48-9675-4513-881b-d5a89d801035
REPORT RequestId: ac4d9b48-9675-4513-881b-d5a89d801035 Init Duration: 0.76 ms Duration: 3895.27 ms Billed Duration: 3896 ms Memory Size: 128 MB Max Memory Used: 128 MB
{"status_code": 404, "body": "{\"status\": \"task does not exist\"}"}%
@a-toms
a-toms / #_section_4:_connect_your_serverless_function_to_your_django_app_-_code_block_3_2.txt
Created September 14, 2023 17:23
# Section 4: Connect your Serverless Function to your Django app - Code Block 3
sam build
sam local invoke --event events/event.json
@a-toms
a-toms / #_section_4:_connect_your_serverless_function_to_your_django_app_-_code_block_2_1.txt
Created September 14, 2023 17:23
# Section 4: Connect your Serverless Function to your Django app - Code Block 2
{
"body": {"task_id": 1},
"httpMethod": "POST"
}
@a-toms
a-toms / #_section_4:_connect_your_serverless_function_to_your_django_app_-_code_block_1_0.txt
Created September 14, 2023 17:23
# Section 4: Connect your Serverless Function to your Django app - Code Block 1
# sim/views.py
import requests
import json
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from django.http import JsonResponse
from .models import TaskResult
def dashboard(request):