Flask turns simple hello into text/html, below is flask documenation.
1. Create a Virtual Environment for flask
Change folder’s operation permission; folder ‘web server’ has issue, so use ‘web’ instead.
If the folder contains space, it may have errors
Create a virtual environment on Linux
Install Flask
The ready environment will be like this.
2. Prepare HTML5 CSS Template
Download free scripts from website https://html5up.net/, because flask is taking *.html files from folder templates, and *.js and *.css from folder static, so put the files in the folders like below:
server.py is the file we are going to config and run,
assets
, images
and index.html
is what we downloaded, Otherfiles and folders are created by the venv.
Since we have changed the folders relative location, we need to modify the path in some files when calling other files, we can do it when we debug
server.py
. Those 404 pages are because of path errors.3. Debug server.py in debug mode
- Return a message when submit form successfully
- Save the submitted message into csv file and txt file
- Backup the csv file when the server stopped(Ctrl+C)