Skip to content

Commit

Permalink
Versioning and QOL
Browse files Browse the repository at this point in the history
  • Loading branch information
kompoth committed Apr 11, 2024
1 parent d389cd8 commit 060ab42
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Some of them are listed in the `requirements.txt` file.
Special mentions:
- [Python-Markdown](https://github.com/Python-Markdown/markdown) - HTML generation.
- [Weasyprint](https://github.com/Kozea/WeasyPrint) - PDF generation.
- [magic.css](https://css.winterveil.net/) - CSS framework for the web page.
- [magic.css](https://css.winterveil.net/) - web page CSS.
- [bashcorpo](https://www.deviantart.com/bashcorpo) - paper texture.
- [TT2020](https://copypaste.wtf/TT2020/docs/) - typewriter font (SIL Open Font License).
- [KJV1611](https://github.com/ctrlcctrlv/kjv1611) - blackletter font (SIL Open Font License).
Expand Down
1 change: 1 addition & 0 deletions muckraker/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1"
25 changes: 18 additions & 7 deletions muckraker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse

from . import __version__
from .models import Issue
from .render import render_issue

Expand All @@ -21,7 +22,17 @@
ACCEPTED_FILE_TYPES = ("image/png", "image/jpeg", "image/jpg")
IMAGE_SUFFIXES = (".png", ".jpeg", ".jpg")

app = FastAPI(root_path="/api")
# Setup the application
tags_metadata = [{"name": "issue"}]
app = FastAPI(
title="Muckraker",
root_path="/api",
version=__version__,
summary="A vintage gazette generator for your creative projects.",
openapi_tags=tags_metadata
)

# Configure CORS policy
origins = ["*"]
app.add_middleware(
CORSMiddleware,
Expand All @@ -48,17 +59,17 @@ async def clear_tempdir_handler(request, exc):
)


@app.post("/issue/")
async def create_s_issue(issue: Issue):
@app.post("/issue/", tags=["issue"])
async def upload_issue_data(issue: Issue):
dir_path = mkdtemp(prefix="muckraker")
issue_path = Path(dir_path) / "issue.json"
with open(issue_path, "w") as fd:
fd.write(issue.model_dump_json())
return {"issue_id": dir_path.split("muckraker")[-1]}


@app.patch("/issue/{issue_id}")
async def patch_s_issue(
@app.patch("/issue/{issue_id}", tags=["issue"])
async def upload_images(
dir_path: Path = Depends(get_dir_path),
images: List[UploadFile] = File()
):
Expand Down Expand Up @@ -97,8 +108,8 @@ async def patch_s_issue(
return JSONResponse(content={"filename": image.filename})


@app.get("/issue/{issue_id}")
async def get_s_issue(dir_path: Path = Depends(get_dir_path)):
@app.get("/issue/{issue_id}", tags=["issue"])
async def get_issue(dir_path: Path = Depends(get_dir_path)):
# Read issue data
with open(dir_path / "issue.json", "r") as fd:
issue_dict = json.load(fd)
Expand Down
3 changes: 1 addition & 2 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ async function generatePDF() {

var resp;
var respJson;
//const resourceUrl = "/api/issue/";
const resourceUrl = "http://127.0.0.1:8001/issue/";
const resourceUrl = "/api/issue/";

try {
resp = await fetch(resourceUrl, {
Expand Down

0 comments on commit 060ab42

Please sign in to comment.