diff --git a/Lesson_5/Task 3/.gitignore b/Lesson_5/Task 3/.gitignore new file mode 100644 index 0000000..cf9559d --- /dev/null +++ b/Lesson_5/Task 3/.gitignore @@ -0,0 +1 @@ +articles.txt \ No newline at end of file diff --git a/Lesson_5/Task 3/templates/editor.html b/Lesson_5/Task 3/templates/editor.html new file mode 100644 index 0000000..0add54c --- /dev/null +++ b/Lesson_5/Task 3/templates/editor.html @@ -0,0 +1,15 @@ + + + + Editor + + +
+
+
+
+
+ +
+ + diff --git a/Lesson_5/Task 3/templates/index.html b/Lesson_5/Task 3/templates/index.html new file mode 100644 index 0000000..0af8d62 --- /dev/null +++ b/Lesson_5/Task 3/templates/index.html @@ -0,0 +1,12 @@ + + + + News + + +
+ {{contents|safe}} +
+ Add + + diff --git a/Lesson_5/Task 3/webserver.py b/Lesson_5/Task 3/webserver.py new file mode 100644 index 0000000..ebcdb44 --- /dev/null +++ b/Lesson_5/Task 3/webserver.py @@ -0,0 +1,23 @@ +from flask import Flask, render_template, redirect, request +from datetime import datetime + +app = Flask("News") + +@app.route('/') +def index(): + with open("articles.txt", "r") as file: + data = file.read() + return render_template("index.html", contents=data) + +@app.route('/editor') +def editor(): + return render_template("editor.html") + + +@app.route('/process.html') +def process(): + with open("articles.txt", "a") as file: + file.write("

" + str(request.args.get('title')) + "

\n

" + str(datetime.now()) + "

\n

" + str(request.args.get('text')) + "


\n") + return redirect('/') + +app.run(port=8080) diff --git a/README.md b/README.md index afd11d7..46ec827 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,26 @@ Checked means the task is Done. ### Lesson 2 - [ ] Task 1 +- [x] Task 2 +- [ ] Task 3 +- [ ] Task 4 +- [x] Task 5 +- [ ] Task %*f#ncA0#>? + +### Lesson 3 +- [ ] Task 1 +- [ ] Task 2 +- [ ] Task 3 +- [ ] Task K3F9#@%^&? + +### Lesson 4 +- [ ] Task 1 + +### Lesson 5 - [ ] Task 2 - [ ] Task 3 - [ ] Task 4 -- [ ] Task 5 -- [ ] Task %*f#ncA0#>? + +### Lesson 6 +- [ ] Task 1 +- [ ] Task 2