Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def read_file():
- try:
- with open('text.txt') as f:
- return f.readlines()
- except FileNotFoundError:
- return 'Source file missing or corrupted.'
- def write_file(contents: str):
- with open('text.txt', 'a') as f:
- f.write(contents)
- @app.route('/update', methods=['POST'])
- def update():
- contents = request.form['input']
- write_file(contents)
- write_file(' - ')
- write_file(getdate())
- write_file('n')
- return redirect('/editor')
- @app.route('/editor')
- def editor():
- contents = read_file()
- date = getdate()
- return render_template('editor.html',
- contents = contents,
- title='Editor',
- date = date)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement