Homework #2
Reading → Coding → Deploy → Code-review
Reading
-
Python Flask big tutorial
1.1 https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
1.2. https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-ii-templates
- HTML forms: https://www.w3schools.com/html/html_forms.asp
- Markdown: https://guides.github.com/features/mastering-markdown/
Coding
Preparations
- Install Python programming language v3.8.2: https://www.python.org/downloads/
- Install Flask framework with pip: https://docs.python.org/3/installing/index.html#basic-usage
Basic part
-
Create web application, which can host your image gallery:
1.1. Listen on
localhost:5000
1.2. Render HTML document on
http://localhost:5000/
1.3. Show static images on
http://localhost:5000/img/<image_name>
1.4. Your external CSS and JS files should be returned on
http://localhost:5000/static/<js/css filename>
- You are allowed to use any JS or CSS frameworks
- You are allowed to use only Python programming language and Flask framework
Optimal part
-
Create web application, which emulates a chat with a human:
1.1. Web page with messages log
1.2. Input for writing new message
1.3. Button for sending message to the server
1.4. Sample HTML form:
<form method="POST" action="<http://localhost:5000/>"> <textarea name="messages"></textarea> <input type="text" name="new_message"> <input type="submit"> </form>
-
After the button click message should be sent to the server with
HTTP POST
tohttp://localhost:5000/
:2.1. It is okay to send also all messages if you don’t know how to keep them on the server.
2.2. It is also okay to keep them in the global variable
-
Robot should answer on a message according to the predefined set of rules
3.1. Rules can be hardcoded as bases on the occurencies of different words
3.2. There should be at least 10 rules describing typical conversation topics:
3.2.1. current weather 3.2.2. hello/greetings 3.2.3. ...
Challenging part
(Part for those, who already knows all that stuff)
- Dialog should be kept on the server (global variable or text file)
-
Robot should add new messages independently from user (every second new message)
2.1. It can be done with another python script
2.2. Or it can be done with separate Thread
-
Message updates should be delivered to the user’s page with the help of three methods (you can create three endpoints for this)
3.1. polling new messages every 1 second
3.2. long polling new messages
3.3. (optionally) through websockets
Deploy
- Register on GitHub: https://github.com/
- Join our organization: https://github.com/itmo-wad/
- Create a new personal repository for the second homework
- Commit and push your sources to GitHub. And don’t forget to describe shortly what have you done in
README.md
file. Use Markdown format: https://guides.github.com/features/mastering-markdown/ - (optional) Deploy you sources on Heroku or somewhere else and add link to the server to
README.md
Code-review
- Communicate in Telegram chat
- Help others to complete the assignment