FlaskWebS
This is a simple web application created as part of the Modulus 164 project.
The goal of this project is to show our skills and understanding of web development (Roadmap here).
All database elements (MCD, MLD and dictionary) are in .github/database
Software to download before installing
Required :
Windows :
- Laragon Full - v6.0.0 or newer / or an other database system.
- Gitbash - v2.42.0 or newer.
- Python - v3.12.0 or newer.
Optional :
- Pycharm - v2023.2.3 only if you want to use the other installation.
Installing the Flask application
Windows (Gitbash)
Clone the project by opening gitbash or the terminal.
git clone https://github.com/InstaZDLL/Besson_Ethan_info1a_164_2023.git
Go to the project directory.
cd Besson_Ethan_info1a_164_2023
[Optional] If you hava Laragon you don't have to edit something if your credentials are root with no password.
Modify the environment variables in the .env
file. You can edit the file with Notepad or another text editing tool.
notepad .env
[Optional] If you don't want to change the dump and keep the original database you can skip this step, Change, if needed, the besson_ethan_info_1a.sql
file in the database
directory. You can edit the file with Notepad or another text editing tool.
cd FlaskWebS/database
notepad besson_ethan_info_1a.sql
Return to the root folder of the project and start the server. You can launch the start.bat
file with a double click or in the terminal with .\start.bat
.
.\start.bat
Installation tutorial for Windows :
Standard installation (Gitbash):
Other installation (PyCharm):
Linux
Install the following dependency (You must also have installed python3)
sudo apt install python3-pip
Clone the project.
git clone https://github.com/InstaZDLL/Besson_Ethan_info1a_164_2023.git
Go to the project directory.
cd Besson_Ethan_info1a_164_2023
[Optional] If you hava Laragon you don't have to edit something if your credentials are root with no password.
Modify the environment variables in the .env
file. You can use the following command to edit the file:
nano .env
[Optional] If you don't want to change the dump and keep the original database you can skip this step, Change, if needed, the besson_ethan_info_1a.sql
file in the database
directory.
You can use the following command to edit the file:
cd FlaskWebS/database
nano besson_ethan_info_1a.sql
Return to the root folder of the project and start the server using the following command:
chmod u+x ./start.sh
./start.sh
Installation tutorial for linux :
Environment Variables
To run this project, you will need to modify the following environment variables to your .env
file
USER_MYSQL
PASS_MYSQL
NAME_BD_MYSQL
NAME_FILE_DUMP_SQL_BD
SELECT_QUERY_ENABLED
- Optional, options : true or false ℹ️
ℹ️ This variable is used to show a table from the database, to see if the SQL dump import was successful.
Usage/Examples
Qtagselect Usage
To use qtagselect in the modify_materiel_form.html
-/show_modify_materiel
if you want to change the category of the item you've selected, you need to click on the x to remove the current one, and then select another in the label box.
Step 1 : click on the x to delete the category already selected.
Step 2: select a new category from the tagbox.
Note that you can only select 1 category in the box if you wish to modify it. To select more change the code here
Step 3 : once you've selected a category, close the label box menu by clicking on (Close) at the bottom of the box, or click on any item outside the box, which will automatically close it.
Animated tutorial :
SQL Request modifications :
You can change the SQL request to show an other table.
@bp.route('/stock')
def materiel():
"""
Retrieves the data from the table t_materiel in the MySQL database and displays it on the page "stock.html".
"""
query = "SELECT * FROM t_materiel" # Modify with your query here
cursor.execute(query)
data = cursor.fetchall()
return render_template('stock.html', data=data)
If you change something here don't forget to modify the html code too in the materiel.html
, or you can also opt for automatic headers such as marques.html
.
Note : if you change a request in some case you need to change the js and the form to request so that the information is properly handeled.
Lessons Learned
1. Be specific when asking questions to get the most helpful answers.
2. Use clear and concise language to convey your message effectively.
3. Always backup your important files and documents to avoid losing them.
4. Stay up-to-date with the latest technology trends and tools to improve your productivity.
5. Take breaks and prioritize self-care to avoid burnout.
6. Learning is a lifelong process, and it's important to continually seek knowledge and growth.
Author
License
Copyright (C) 2023 Ethan Besson
Licensed under the Academic Free License version 3.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://opensource.org/license/afl-3-0-php/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.