mirror of
https://github.com/markbeep/AudioBookRequest.git
synced 2026-01-05 13:09:45 -06:00
base setup
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.direnv
|
||||
.venv
|
||||
.env
|
||||
.envrc
|
||||
__pycache__
|
||||
static
|
||||
0
app/__init__.py
Normal file
0
app/__init__.py
Normal file
18
app/db.py
Normal file
18
app/db.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from os import getenv
|
||||
from sqlalchemy import create_engine
|
||||
from sqlmodel import Session
|
||||
|
||||
host = getenv("POSTGRES_HOST", "localhost")
|
||||
password = getenv("POSTGRES_PASSWORD", "docker")
|
||||
user = getenv("POSTGRES_USER", "docker")
|
||||
database = getenv("POSTGRES_DATABASE", "docker")
|
||||
port = getenv("POSTGRES_PORT", "5432")
|
||||
|
||||
engine = create_engine(
|
||||
f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}"
|
||||
)
|
||||
|
||||
|
||||
def get_session():
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
6
app/main.py
Normal file
6
app/main.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from fastapi import FastAPI
|
||||
from app.routers import root
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.include_router(root.router)
|
||||
8
app/models.py
Normal file
8
app/models.py
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
from sqlmodel import SQLModel
|
||||
|
||||
|
||||
class BaseModel(SQLModel):
|
||||
pass
|
||||
|
||||
0
app/routers/__init__.py
Normal file
0
app/routers/__init__.py
Normal file
17
app/routers/root.py
Normal file
17
app/routers/root.py
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi.responses import FileResponse
|
||||
from jinja2_fragments.fastapi import Jinja2Blocks
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
templates = Jinja2Blocks(directory="templates")
|
||||
|
||||
@router.get("/globals.css")
|
||||
def read_globals_css():
|
||||
return FileResponse("static/globals.css")
|
||||
|
||||
@router.get("/")
|
||||
async def read_root(request: Request):
|
||||
return templates.TemplateResponse("root.html", {"request": request, "magic_number": 30})
|
||||
25
flake.lock
generated
Normal file
25
flake.lock
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1731676054,
|
||||
"narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=",
|
||||
"rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add",
|
||||
"revCount": 708622,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.708622%2Brev-5e4fbfb6b3de1aa2872b76d49fafc942626e2add/0193363c-ab27-7bbd-af1d-3e6093ed5e2d/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
25
flake.nix
Normal file
25
flake.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
description = "A Nix-flake-based Python development environment";
|
||||
|
||||
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
});
|
||||
in
|
||||
{
|
||||
devShells = forEachSupportedSystem ({ pkgs }: {
|
||||
default = pkgs.mkShell {
|
||||
venvDir = ".venv";
|
||||
packages = with pkgs; [ python311 ] ++
|
||||
(with pkgs.python311Packages; [
|
||||
pip
|
||||
venvShellHook
|
||||
]);
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
17
pyproject.toml
Normal file
17
pyproject.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[project]
|
||||
name = "audiobookrequest"
|
||||
requires-python = ">= 3.11"
|
||||
dynamic = ["version"]
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.pyright]
|
||||
include = ["**/*.py"]
|
||||
exclude = ["**/__pycache__", "**/.venv"]
|
||||
ignore = []
|
||||
|
||||
typeCheckingMode = "strict"
|
||||
reportUnknownParameterType = true
|
||||
reportMissingParameterType = true
|
||||
48
requirements.txt
Normal file
48
requirements.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
annotated-types==0.7.0
|
||||
anyio==4.8.0
|
||||
black==25.1.0
|
||||
certifi==2025.1.31
|
||||
click==8.1.8
|
||||
dnspython==2.7.0
|
||||
email_validator==2.2.0
|
||||
fastapi==0.115.8
|
||||
fastapi-cli==0.0.7
|
||||
greenlet==3.1.1
|
||||
h11==0.14.0
|
||||
httpcore==1.0.7
|
||||
httptools==0.6.4
|
||||
httpx==0.28.1
|
||||
idna==3.10
|
||||
Jinja2==3.1.5
|
||||
markdown-it-py==3.0.0
|
||||
MarkupSafe==3.0.2
|
||||
mdurl==0.1.2
|
||||
mypy-extensions==1.0.0
|
||||
nodeenv==1.9.1
|
||||
packaging==24.2
|
||||
pathspec==0.12.1
|
||||
platformdirs==4.3.6
|
||||
pydantic==2.10.6
|
||||
pydantic_core==2.27.2
|
||||
Pygments==2.19.1
|
||||
pyright==1.1.394
|
||||
python-dotenv==1.0.1
|
||||
python-multipart==0.0.20
|
||||
PyYAML==6.0.2
|
||||
rich==13.9.4
|
||||
rich-toolkit==0.13.2
|
||||
shellingham==1.5.4
|
||||
sniffio==1.3.1
|
||||
SQLAlchemy==2.0.38
|
||||
sqlmodel==0.0.22
|
||||
starlette==0.45.3
|
||||
typer==0.15.1
|
||||
typing_extensions==4.12.2
|
||||
uvicorn==0.34.0
|
||||
uvloop==0.21.0
|
||||
watchfiles==1.0.4
|
||||
websockets==14.2
|
||||
aiohttp==3.11.12
|
||||
alembic==1.14.1
|
||||
jinja2-fragments==1.7.0
|
||||
pytailwindcss==0.2.0
|
||||
1
styles/globals.css
Normal file
1
styles/globals.css
Normal file
@@ -0,0 +1 @@
|
||||
@import "tailwindcss";
|
||||
12
tailwind.config.js
Normal file
12
tailwind.config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
purge: [],
|
||||
darkMode: false, // or 'media' or 'class'
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
variants: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
content: ["templates/**/*.html"],
|
||||
};
|
||||
14
templates/root.html
Normal file
14
templates/root.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>This is the title</title>
|
||||
<link rel="stylesheet" href="globals.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>This is a header</h1>
|
||||
{% block content %}
|
||||
<p>This is the magic number: {{ magic_number }}.</p>
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user