This PR refactors the post() function in main.py to handle GET and POST requests separately. The current implementation of the post() function does not clearly separate the logic for these two methods, which can lead to confusion and potential bugs.
Summary of Changes
Separated the logic for the GET and POST methods in the post() function using an if-else statement.
For the GET method, fetched all posts from the 'pages' directory and returned them.
For the POST method, handled the creation of a new post by getting the filename and markdown content from the request, writing the markdown content to a new file in the 'pages' directory, and redirecting to the new page.
This PR addresses issue #49 and is based on the branch 'refactor-post-function'.
Fixes #49.
To checkout this PR branch, run the following command in your terminal:
git checkout sweep/refactor-post-function_1
🎉 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. The current implementation of the post() function does not clearly separate the logic for these two methods, which can lead to confusion and potential bugs.
Summary of Changes
This PR addresses issue #49 and is based on the branch 'refactor-post-function'.
Fixes #49.
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: