Closed sweep-ai[bot] closed 1 year ago
This is awesome! If you could first attempt to name the post with a provided request attribute called "filename" or "post_name", that would be awesome. Having the timestamp as a fallback, though, if filename is omitted, is fantastic.
This is awesome! If you could first attempt to name the post with a provided request attribute called "filename" or "post_name", that would be awesome. Having the timestamp as a fallback, though, if filename is omitted, is fantastic.
Hi @SomethingGeneric,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
main.py |
Modify main.py with contents: ā¢ In the post() function, check for the presence of the "filename" or "post_name" attribute in the request.ā¢ If the attribute is present, use its value as the filename for the new post. ā¢ If the attribute is not present, fallback to using the current timestamp to generate a unique filename. |
Description
This PR implements the functionality to save a post as a markdown file in the Flaskpress application. It modifies the
post()
function inmain.py
to handle incoming POST requests with a markdown text attribute. The markdown text is extracted from the request, and a unique filename is generated for the new post. The markdown file is then saved in thepages/
directory. If thepages/
directory does not exist, it is created. After saving the markdown file, thepost()
function returns a redirect to the new post's page.Summary of Changes
post()
function inmain.py
to handle incoming POST requests with a markdown text attribute.request.form.get('markdown')
.pages/
directory exists and created it if it does not.pages/
directory with the generated filename and wrote the markdown text to it.post()
function to return a redirect to the new post's page usingreturn redirect(url_for('page', filename=filename))
.Fixes #6.
To checkout this PR branch, run the following command in your terminal:
š Latest improvements to Sweep:
š” To get Sweep to edit this pull request, you can: