This PR refactors the post() function in main.py to handle GET and POST requests separately. It improves the readability and maintainability of the code by clearly separating the handling of these two methods.
Summary of Changes
Refactored the post() function to handle GET and POST requests separately.
For GET requests, the function now returns all posts by reading the files in the 'pages' directory and appending their content to a list.
For POST requests, the function now handles the creation of a new post by getting the post data from the request, writing it to a new file in the 'pages' directory, and redirecting to the new post's page.
Added a check to ensure that the 'pages' directory exists before attempting to read from or write to it. If the directory does not exist, it is created.
Please review and merge this PR. Thank you!
Fixes #27.
To checkout this PR branch, run the following command in your terminal:
git checkout sweep/refactor-post-function
🎉 Latest improvements to Sweep:
Use Sweep Map to break large issues into smaller sub-issues, perfect for large tasks like "Sweep (map): migrate from React class components to function components"
Getting Sweep to format before committing! Check out Sweep Sandbox Configs to set it up.
We released a demo of our chunker, where you can find the corresponding blog and code.
💡 To get Sweep to edit this pull request, you can:
Leave a comment below to get Sweep to edit the entire PR
Leave a comment in the code will only modify the file
Edit the original issue to get Sweep to recreate the PR from scratch
Description
This PR refactors the post() function in main.py to handle GET and POST requests separately. It improves the readability and maintainability of the code by clearly separating the handling of these two methods.
Summary of Changes
Please review and merge this PR. Thank you!
Fixes #27.
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: