generally reorganize

main
Ryan Rix 2021-09-18 18:25:16 -07:00
parent 6eb8cd7def
commit 7898eef203
1 changed files with 46 additions and 40 deletions

View File

@ -66,14 +66,15 @@ in pkgs.mkShell {
}
#+end_src
** FastAPI Server initialization
* FastAPI HTTP Server
:PROPERTIES:
:ID: 20210918T172533.031317
:END:
- Set up FastAPI
- [[id:20210918T172550.522530][Create the DB]] using metadata attached to the =SQLModel= class
- Set up FastAPI; =uvicorn server:app= will use that FastAPI =app= object.
- Set up Jinja2: =templates= is a [[https://fastapi.tiangolo.com/advanced/templates/][FastAPI]] helper which can easily render things tangled in to [[file:./templates/][./templates]].
- [[id:20210918T172550.522530][Create the DB]] using metadata attached to the =SQLModel= class, make sure an =engine= is lying around for querying.
#+begin_src python :tangle server.py :noweb yes
from typing import Optional
@ -91,7 +92,7 @@ templates = Jinja2Templates(directory="templates")
<<index-endpoints>>
#+end_src
Some really basic template:
** Some really basic app template:
#+begin_src jinja2 :tangle templates/base.html.j2
<!DOCTYPE html>
@ -121,6 +122,47 @@ Some really basic template:
</html>
#+end_src
** INPROGRESS index view
:LOGBOOK:
- State "INPROGRESS" from "NEXT" [2021-09-18 Sat 18:15]
:END:
This page will list all the items with some sort of pagination strategy.
#+begin_src python :noweb-ref index-endpoints
from fastapi.responses import HTMLResponse
from fastapi import Request
@app.get("/", response_class=HTMLResponse)
async def read_root(request: Request):
return templates.TemplateResponse("index.html.j2", {"request": request})
#+end_src
#+begin_src jinja2 :tangle templates/index.html.j2
{% extends "base.html.j2" %}
{% block title %}Index of Inventory{% endblock %}
{% block head %}{% endblock %}
{% block content %}
<h1>Index</h1>
<p class="important">
Welcome to my awesome homepage.
</p>
{% endblock %}
#+end_src
** NEXT mobile-friendly capture interface
- image upload, clean up with imagemagick or so
- fast metadata creation
- "insert into"
- "move to"
** NEXT search field
just a quick name -> thing search, maybe description, too
** NEXT dynamic autocomplete for object names, inline move-to, insert-into.
* Data Models
:LOGBOOK:
CLOCK: [2021-09-18 Sat 16:56]--[2021-09-18 Sat 16:58] => 0:02
@ -236,42 +278,6 @@ def create_db_and_tables():
return engine()
#+end_src
* NEXT mobile-friendly capture interface
- image upload, clean up with imagemagick or so
- fast metadata creation
- "insert into"
- "move to"
* NEXT index view
#+begin_src python :noweb-ref index-endpoints
from fastapi.responses import HTMLResponse
from fastapi import Request
@app.get("/", response_class=HTMLResponse)
async def read_root(request: Request):
return templates.TemplateResponse("index.html.j2", {"request": request})
#+end_src
#+begin_src jinja2 :tangle templates/index.html.j2
{% extends "base.html.j2" %}
{% block title %}Index of Inventory{% endblock %}
{% block head %}{% endblock %}
{% block content %}
<h1>Index</h1>
<p class="important">
Welcome to my awesome homepage.
</p>
{% endblock %}
#+end_src
* NEXT search field
just a quick name -> thing search, maybe description, too
* NEXT dynamic autocomplete for object names, inline move-to, insert-into.
* NEXT sqlite queries
these can just stay in the notebook and run against the (read-only!!!!!! I promise!!!!) database on my laptop, unless i have mobile usecases for them that can't be solved with a linux shell access on my phone? idonno.