SomethingGeneric / flaskpress

Wordpress but it's actually Python + Flask
GNU General Public License v3.0
0 stars 0 forks source link

Sweep: Refactor post method #40

Closed sweep-ai[bot] closed 1 year ago

sweep-ai[bot] commented 1 year ago

Parent issue: #13

Checklist - [ ] `main.py` > • Refactor the post() function to handle GET and POST requests separately. Use the request.method attribute to determine the type of the request. > • For the GET method, read all the files in the 'pages' directory and return their content. Use the os.listdir() function to get the list of files and the open() function in a loop to read their content. > • For the POST method, get the filename and markdown content from the request using the request.form.get() function. Write the content to a new file in the 'pages' directory using the open() function with the 'w' mode. After writing the content, redirect to the new page using the redirect() function and the url_for() function.
sweep-ai[bot] commented 1 year ago

66%


❌ Unable to Complete PR

I'm sorry, but it looks like an error has occurred. Try changing the issue description to re-trigger Sweep. If this error persists contact team@sweep.dev.

For bonus GPT-4 tickets, please report this bug on Discord.


Please look at the generated plan. If something looks wrong, please add more details to your issue.

File Path Proposed Changes
main.py Modify main.py with contents:
• Refactor the post() function to handle GET and POST requests separately. Use the request.method attribute to determine the type of the request.
• For the GET method, read all the files in the 'pages' directory and return their content. Use the os.listdir() function to get the list of files and the open() function in a loop to read their content.
• For the POST method, get the filename and markdown content from the request using the request.form.get() function. Write the content to a new file in the 'pages' directory using the open() function with the 'w' mode. After writing the content, redirect to the new page using the redirect() function and the url_for() function.

🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description.