Skip to content

Commit

Permalink
Try out json?
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhariri committed Oct 16, 2024
1 parent 4b0d3c0 commit ecdac38
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,37 +118,36 @@ def micropub():
"actions": ["create", "update", "delete"],
"types": ["h-entry"],
"syndicate-to": [
"https://dhariri.com/blog/",
f"{settings.FQD}/blog/",
]
}
return jsonify(response)
elif request.method == 'POST':
if not verify_access_token():
abort(401, description="Invalid or missing access token.")

print(request.form)
print(request.json)

# Parse Micropub request
h = request.form.get('h', 'entry') # default to 'entry'
h = request.json.get('h', 'entry') # default to 'entry'
if h != 'entry':
abort(400, description="Unsupported type.")

content = request.form.get('content', '').strip()
content = request.json.get('content', '').strip()
if not content:
abort(400, description="Missing content.")

title = request.form.get('title')
categories = request.form.getlist('category') # tags
title = request.json.get('title')
categories = request.json.get('category', []) # tags

# Start of Selection
url_slug = slugify(title) if title else str(uuid.uuid4())

post = create_post(
title=title,
content=content,
url_slug=url_slug,
tags=set(categories) if categories else None,
description=request.form.get('summary')
description=request.json.get('summary')
)

post_url = urljoin(settings.FQD, f"/blog/{post.url_slug}/")
Expand Down

0 comments on commit ecdac38

Please sign in to comment.