Is this the initial commit? I forgot

This commit is contained in:
2025-10-13 18:05:41 +01:00
parent af38770285
commit 25e0ec2c60
5 changed files with 37 additions and 7 deletions

23
main.py
View File

@@ -2,6 +2,8 @@ from flask import Flask, render_template, request, redirect
from markdown_it import MarkdownIt
import os
import config
import functions
import data_management
md = MarkdownIt().enable('table')
@@ -46,18 +48,25 @@ def edit_page(page):
# Forms
@app.route('/submit-edit', methods=['POST'])
def handle_data():
def submit_edit_page():
page = request.form['page']
content = request.form['content']
username = request.form['username']
password = request.form['password']
password_hash = functions.sha512_hash(request.form['password'])
with open(f'./wiki-pages/{page}.md', 'w') as file:
print(content)
file.write(content)
file.close()
user_object = data_management.get_data('users', 'username', username)
print(user_object['password_hash'])
print(password_hash)
if user_object['password_hash'] == password_hash:
with open(f'./wiki-pages/{page}.md', 'w') as file:
file.write(content)
file.close()
return redirect(f'/wiki/{page}', 302)
else:
return 'Incorrect password'
return redirect(f'/wiki/{page}', 302)
if __name__ == '__main__':