From 00adb8b6f9564c50727d3cb27203ddd60589aff1 Mon Sep 17 00:00:00 2001 From: DaanoGames Date: Wed, 12 Mar 2025 16:11:50 +0100 Subject: [PATCH 01/70] login page created --- login_page.html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 login_page.html diff --git a/login_page.html b/login_page.html new file mode 100644 index 0000000..1ae3595 --- /dev/null +++ b/login_page.html @@ -0,0 +1,11 @@ + + + + + + Login Page + + + + + \ No newline at end of file From 70063c58edd2e7c2a06062656cb9b4bda619d432 Mon Sep 17 00:00:00 2001 From: Stef Date: Wed, 12 Mar 2025 16:17:53 +0100 Subject: [PATCH 02/70] Creating run.py for flask server --- run.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 run.py diff --git a/run.py b/run.py new file mode 100644 index 0000000..e92fc1d --- /dev/null +++ b/run.py @@ -0,0 +1,3 @@ +from flask import Flask + +app = Flask("__name__") From a5d43f2f68aa8bfe2bc784ba4f46813b60184588 Mon Sep 17 00:00:00 2001 From: Stef Date: Wed, 12 Mar 2025 16:18:27 +0100 Subject: [PATCH 03/70] Added venv lines to readme --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b407ac5..3b06851 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -# WebTech \ No newline at end of file +# WebTech + +python -m venv venv +pip install -r requirements.txt \ No newline at end of file From 205f5b1cf6a1a716d59e9eb63e57a268267f0ccb Mon Sep 17 00:00:00 2001 From: Stef Date: Thu, 13 Mar 2025 12:56:37 +0100 Subject: [PATCH 04/70] updated run.py to start flask server and added a default route for webpage --- run.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/run.py b/run.py index e92fc1d..c83968b 100644 --- a/run.py +++ b/run.py @@ -1,3 +1,17 @@ from flask import Flask +# Create Flask instance app = Flask("__name__") + + +# Default app route +@app.route("/") +def index(): + # Return HTML content + return "

This is the default page

" + + +# Prevent execution when imported by other script +if __name__ == "__main__": + # Start the flask server in debug mode for development purposes + app.run(port=80, debug=True) From 028e550db6884af0c404bcc5a2ba20991428617d Mon Sep 17 00:00:00 2001 From: Stef Date: Thu, 13 Mar 2025 13:04:55 +0100 Subject: [PATCH 05/70] Added folder for images (static) and a folder for HTML pages (templates) --- static/.gitkeep | 0 templates/.gitkeep | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/.gitkeep create mode 100644 templates/.gitkeep diff --git a/static/.gitkeep b/static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 0000000..e69de29 From 6ac14893aa326b02406ded7f71ee5f44fc47d77e Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 24 Mar 2025 09:44:39 +0100 Subject: [PATCH 06/70] Added pip packages and added it to readme - Flask-WTF - pillow - WTForms --- README.md | 4 +++- requirements.txt | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b06851..8aa4f8f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# WebTech +# Updating requirements.txt +pip freeze > requirements.txt +# Installing required packages python -m venv venv pip install -r requirements.txt \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index af7203e..6bd975a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,10 @@ blinker==1.9.0 click==8.1.8 colorama==0.4.6 Flask==3.1.0 +Flask-WTF==1.2.2 itsdangerous==2.2.0 Jinja2==3.1.6 MarkupSafe==3.0.2 +pillow==11.0.0 Werkzeug==3.1.3 +WTForms==3.2.1 From e9062308e5f3e37f43f3b3ba984a8d90f8b80630 Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 24 Mar 2025 10:06:32 +0100 Subject: [PATCH 07/70] Create dashboard.html --- templates/dashboard.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 templates/dashboard.html diff --git a/templates/dashboard.html b/templates/dashboard.html new file mode 100644 index 0000000..bdb612a --- /dev/null +++ b/templates/dashboard.html @@ -0,0 +1,14 @@ + + + + + + + Dashboard + + + + + + + \ No newline at end of file From cb8e5e035d32eb26579e09d1f00259cc9727a56d Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 24 Mar 2025 10:11:50 +0100 Subject: [PATCH 08/70] Create navbar_base.html --- templates/navbar_base.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 templates/navbar_base.html diff --git a/templates/navbar_base.html b/templates/navbar_base.html new file mode 100644 index 0000000..e7e3f59 --- /dev/null +++ b/templates/navbar_base.html @@ -0,0 +1,14 @@ + + + + + + + Default + + + + + + + \ No newline at end of file From a8db4f7b70eb4c859d0e4068e7995a4f829caa00 Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 1 Apr 2025 11:08:04 +0200 Subject: [PATCH 09/70] Update requirements.txt Added flask-wtf and flask-login packages --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6bd975a..6d657b5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,10 +2,10 @@ blinker==1.9.0 click==8.1.8 colorama==0.4.6 Flask==3.1.0 +Flask-Login==0.6.3 Flask-WTF==1.2.2 itsdangerous==2.2.0 Jinja2==3.1.6 MarkupSafe==3.0.2 -pillow==11.0.0 Werkzeug==3.1.3 WTForms==3.2.1 From 1f8323dd9b34e1d310f75092ed1e10c70df4e6a4 Mon Sep 17 00:00:00 2001 From: DaanoGames Date: Tue, 1 Apr 2025 11:08:21 +0200 Subject: [PATCH 10/70] base template made login page deleted, base template in map templates made --- templates/base_template.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 templates/base_template.html diff --git a/templates/base_template.html b/templates/base_template.html new file mode 100644 index 0000000..89afbe5 --- /dev/null +++ b/templates/base_template.html @@ -0,0 +1,14 @@ + + + + + + + + {% block title %}{% endblock title %} + + + {% block content %} + {% endblock %} + + \ No newline at end of file From 9bbb8855160bd95c0a1673b93ad015ef6497ccaa Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 1 Apr 2025 11:12:17 +0200 Subject: [PATCH 11/70] Updating requirements.txt Added pillow --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 6d657b5..c152f85 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,6 @@ Flask-WTF==1.2.2 itsdangerous==2.2.0 Jinja2==3.1.6 MarkupSafe==3.0.2 +pillow==11.1.0 Werkzeug==3.1.3 WTForms==3.2.1 From f660a33425d20ed45093e3de4fa8cf4bfc805a27 Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 1 Apr 2025 11:51:20 +0200 Subject: [PATCH 12/70] Adding forms testing --- __pycache__/forms.cpython-312.pyc | Bin 0 -> 886 bytes forms.py | 13 +++++++++++++ run.py | 16 ++++++++++++++-- templates/forms.html | 23 +++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 __pycache__/forms.cpython-312.pyc create mode 100644 forms.py create mode 100644 templates/forms.html diff --git a/__pycache__/forms.cpython-312.pyc b/__pycache__/forms.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c61de8db4e9428e6cffc59aeadb3fecce9865af1 GIT binary patch literal 886 zcmZ`%ON-M`6h1evCTZ)U${@PXjY1HLBFv&lT}SsXx+H-o}@)b@Gic4UiUn{b3at8I`DJn-S@#O0`L`; z)sdIN+~UF!xZn~W0%8(^vfvAWXo`VkN`Y+3xlQzypk$T^2(SsRGzM3uWGWVUOf|PE z+*Pr<+aI+x1IOhle-(I z<Zj_Bmu+@&mEhbmmUO|q!re!(TE>VNLZ)@1 zffpimT|;CTz^Vur5NZf{&Pyn*tpLMf9C-|%CAEk^C-SK6;y1GQlU;_NFDr2g=PSs= zM+I%QrM>=VKRLAp33;jWThis is the default page" +@app.route("/forms") +def forms(): + service_form = ServiceForm() + + if service_form.validate_on_submit: # type: ignore + session["name"] + + return render_template("forms.html", form=service_form) + + # Prevent execution when imported by other script if __name__ == "__main__": # Start the flask server in debug mode for development purposes diff --git a/templates/forms.html b/templates/forms.html new file mode 100644 index 0000000..ed55008 --- /dev/null +++ b/templates/forms.html @@ -0,0 +1,23 @@ + + + + + + + Testing + + + +

Hallo

+
+ {{ form.hidden_tag() }} + {{ form.naam.label }} {{form.naam}} +
+ {{ form.url.label}} {{form.url}} +
+ {{ form.submit() }} +
+ + + + \ No newline at end of file From a0742c07ad23c1d5ced1c7dc10ee2d1b075b77c2 Mon Sep 17 00:00:00 2001 From: DaanoGames Date: Tue, 1 Apr 2025 11:55:33 +0200 Subject: [PATCH 13/70] bases html pages --- run.py | 5 +++++ templates/base_template.html | 3 +++ templates/dashboard.html | 17 +++++------------ templates/login_page.html | 0 templates/navbar_base.html | 21 +++++++-------------- 5 files changed, 20 insertions(+), 26 deletions(-) create mode 100644 templates/login_page.html diff --git a/run.py b/run.py index 1e92373..42cd158 100644 --- a/run.py +++ b/run.py @@ -12,6 +12,11 @@ def index(): # Return HTML content return "

This is the default page

" +@app.route("/dashboard") +def dashboard(): + # Return Dashboard.html + return render_template("dashboard.html") + @app.route("/forms") def forms(): diff --git a/templates/base_template.html b/templates/base_template.html index 89afbe5..a3790a7 100644 --- a/templates/base_template.html +++ b/templates/base_template.html @@ -9,6 +9,9 @@ {% block content %} + {% include "navbar_base.html" %} + {% block navbar %} + {% endblock %} {% endblock %} \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html index bdb612a..da56b53 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -1,14 +1,7 @@ - - +{% extends "base_template.html" %} - - - - Dashboard - +{%block title%}Dashboard{%endblock%} - - - - - \ No newline at end of file +{%block content%} + +{%endblock%} \ No newline at end of file diff --git a/templates/login_page.html b/templates/login_page.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/navbar_base.html b/templates/navbar_base.html index e7e3f59..d58afb9 100644 --- a/templates/navbar_base.html +++ b/templates/navbar_base.html @@ -1,14 +1,7 @@ - - - - - - - Default - - - - - - - \ No newline at end of file +{%block navbar%} + +{%endblock%} From 6e9df34452bf2974b6cd90bc389346ee05d168d3 Mon Sep 17 00:00:00 2001 From: Stef Date: Tue, 1 Apr 2025 12:08:56 +0200 Subject: [PATCH 14/70] More forms testing --- __pycache__/forms.cpython-312.pyc | Bin 886 -> 880 bytes forms.py | 4 ++-- run.py | 12 +++++++----- templates/forms.html | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/__pycache__/forms.cpython-312.pyc b/__pycache__/forms.cpython-312.pyc index c61de8db4e9428e6cffc59aeadb3fecce9865af1..644cca52201c439879baa6379515818b84bcad7a 100644 GIT binary patch delta 106 zcmeyy_JNJ}G%qg~0}vGLc%5FekvD`2tflkpZ;Sz=CRN@7WVQE?SdaB5LmW^$@R zXpoQ9EzXeq)Uy24^whk`t&FBjiMf;aFm|&@U*=Wa?9If(D5*9<^9utrquLi9Mn=vF NoL?D$RFN>y3IH1MAThis is the default page" -@app.route("/forms") +@app.route("/forms", methods=["GET", "POST"]) def forms(): - service_form = ServiceForm() + form = ServiceForm() - if service_form.validate_on_submit: # type: ignore - session["name"] + if form.validate_on_submit: # type: ignore + session["name"] = form.name.data + session["url"] = form.url.data - return render_template("forms.html", form=service_form) + form = ServiceForm(formdata=None) + return render_template("forms.html", form=form) # Prevent execution when imported by other script diff --git a/templates/forms.html b/templates/forms.html index ed55008..87b65de 100644 --- a/templates/forms.html +++ b/templates/forms.html @@ -11,7 +11,7 @@

Hallo

{{ form.hidden_tag() }} - {{ form.naam.label }} {{form.naam}} + {{ form.name.label }} {{form.name}}
{{ form.url.label}} {{form.url}}
From c87ed9cbd6429a96b9887ac6e61bf49069ace51a Mon Sep 17 00:00:00 2001 From: DaanoGames Date: Tue, 1 Apr 2025 12:10:54 +0200 Subject: [PATCH 15/70] changes html pages --- templates/base_template.html | 4 +--- templates/dashboard.html | 2 +- templates/login_page.html | 7 +++++++ templates/navbar_base.html | 12 +++++------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/templates/base_template.html b/templates/base_template.html index a3790a7..fa039f9 100644 --- a/templates/base_template.html +++ b/templates/base_template.html @@ -9,9 +9,7 @@ {% block content %} - {% include "navbar_base.html" %} - {% block navbar %} - {% endblock %} + {% include "navbar_base.html" %} {% endblock %} \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html index da56b53..dcbc352 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -3,5 +3,5 @@ {%block title%}Dashboard{%endblock%} {%block content%} - +

The dashboard will display here

{%endblock%} \ No newline at end of file diff --git a/templates/login_page.html b/templates/login_page.html index e69de29..58592c4 100644 --- a/templates/login_page.html +++ b/templates/login_page.html @@ -0,0 +1,7 @@ +{%extends "base_template.html"%} + +{%block title%}Login{%endblock%} + +{%block content%} + +{%endblock%} \ No newline at end of file diff --git a/templates/navbar_base.html b/templates/navbar_base.html index d58afb9..14e02c8 100644 --- a/templates/navbar_base.html +++ b/templates/navbar_base.html @@ -1,7 +1,5 @@ -{%block navbar%} - -{%endblock%} + From 66d79eeb8925637c650b272f636fcf02d3bef52d Mon Sep 17 00:00:00 2001 From: Stef Date: Thu, 3 Apr 2025 15:52:27 +0200 Subject: [PATCH 16/70] Copied structure and files from Roos --- app.py | 13 ++++++ application/__init__.py | 39 +++++++++++++++++ .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 1410 bytes .../auth/__pycache__/forms.cpython-312.pyc | Bin 0 -> 724 bytes .../auth/__pycache__/models.cpython-312.pyc | Bin 0 -> 844 bytes .../auth/__pycache__/views.cpython-312.pyc | Bin 0 -> 1967 bytes application/auth/forms.py | 8 ++++ application/auth/models.py | 8 ++++ application/auth/templates/login.html | 18 ++++++++ application/auth/views.py | 40 +++++++++++++++++ application/templates/base.html | 41 ++++++++++++++++++ application/templates/home.html | 9 ++++ requirements.txt | 7 +++ 13 files changed, 183 insertions(+) create mode 100644 app.py create mode 100644 application/__init__.py create mode 100644 application/__pycache__/__init__.cpython-312.pyc create mode 100644 application/auth/__pycache__/forms.cpython-312.pyc create mode 100644 application/auth/__pycache__/models.cpython-312.pyc create mode 100644 application/auth/__pycache__/views.cpython-312.pyc create mode 100644 application/auth/forms.py create mode 100644 application/auth/models.py create mode 100644 application/auth/templates/login.html create mode 100644 application/auth/views.py create mode 100644 application/templates/base.html create mode 100644 application/templates/home.html diff --git a/app.py b/app.py new file mode 100644 index 0000000..d5f03e8 --- /dev/null +++ b/app.py @@ -0,0 +1,13 @@ +from application import app +from flask import render_template + + +# home route +@app.route("/") +def index(): + return render_template("home.html") + + +# App deployment +if __name__ == "__main__": + app.run(debug=True, port=5000) diff --git a/application/__init__.py b/application/__init__.py new file mode 100644 index 0000000..8bb7f47 --- /dev/null +++ b/application/__init__.py @@ -0,0 +1,39 @@ +from flask import Flask +from flask_sqlalchemy import SQLAlchemy +from flask_migrate import Migrate +from flask_login import LoginManager # type: ignore + +# App Config +app = Flask(__name__) +app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///services.sqlite" +app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False # Wat is dit? +app.config["SECRET_KEY"] = "bvjchsygvduycgsyugc" # Andere secret key + +# Object Relational Management +db = SQLAlchemy() +db.init_app(app) + +migrate = Migrate(app, db) + +# bp import +from application.auth.views import auth_blueprint + +# from application.strike.views import strike_blueprint + +# Login manager +from application.auth.models import User + +login_manager = LoginManager() +login_manager.init_app(app) # type: ignore +login_manager.login_view = "auth.login" # type: ignore + + +@login_manager.user_loader # type: ignore +def load_user(user_id): # type: ignore + return User.query.get(int(user_id)) # type: ignore + + +# Blueprint magic + +# app.register_blueprint(strike_blueprint, url_prefix="/staking") +app.register_blueprint(auth_blueprint, url_prefix="/auth") diff --git a/application/__pycache__/__init__.cpython-312.pyc b/application/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..295154dd21a18e6891765584aaa889ad4ceb50bc GIT binary patch literal 1410 zcmah}&1)M+6o0cTX{}xB!%AZ(cIgL6kwsH0l%9lfQDwO{u^nnFlnBAF+8wXg-IbL6 za4J)ZLJDzCG4zl^`wtZN&{MDd1A4KDL&Sg&p}q7H984}bb!J!Vn1+xCJNw@6&Aj=& zkKMmgDH)jjvG>f-V*r11BNAo@a?(Qp4?zbVSzx0&LR=Rt!4~Ucpo><_j@RRX9yuZ$NFy0N^IJCJhoC!F$o;@ySBXfMl;uN*va0F?`*($QOT-G=Km z{o9TCw&vTU<++V7O>fa}Hohj!8qqczYNunFn(CSDRs&^15ama@G?P_6y z#y5D+9bO)q4Rp*}sD{mV_=ieUA#8_J;PCoTCB%YSI|+`AVBAt|f-w~tb(+xHtqs$l zg5IPf0eg;0!yt70OnNgx+qO+|+jSHkYT`Ag-PVcahBZzFmts2{LMn$QKTegP*1SN& z>d>4+4Ab>k2TsT3S8({h!pQ}!XIW_9B6CijnY=~rpKLi65kf~WaRm7z`0xlWKTm)( zy1RI{-4h4Xm7aJ{z9Szfm;3P1p!iv2e%yyEgQ=^bxjWm33+z}Td$-XO1|Zy1?kKyJ zL&!dr$M!DmIgjMYp7bIC=+hT6pu*GayFaFTsR5*(z<3|V_uNC68cgMTsYAGMoB$#7 k1WoqQz>% literal 0 HcmV?d00001 diff --git a/application/auth/__pycache__/forms.cpython-312.pyc b/application/auth/__pycache__/forms.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4a3f07459c27fedf7572e355fa41e8da2d70d0b9 GIT binary patch literal 724 zcmYjP&x_MQ6n>MWY0}-&i$51Z^kgoA_98_Vgr!}|T0~cbArPmXX*X-qbY~LF-W2xY z&D-{0kb3a{@Ul`tc0fFM@*=|O#gj9cc5x0b?@QkIz4yJz$9la6>g>MxIl6}czH6{L zm1T0asgh%$Kv4oI!U*ZyO03kzcIsd!t>8-PVi$o09ia9RP=}$pZTPr)SP9%88U#rC z?SzOI?Tn{^BiEkfJRXnQF-xcdML&&m1L}{65YvoP18Xly5>t|ATnvn=iRU9eSNIqh zU_=317BHJ46`lRk-v1PU`4W!MduwhPfL&ExrS@DcK_BcX>{I6)*R%=g?_{HRtf!aW zQ^EL{q%1(ZsuWzhQKjtWO`+Sr)2PMX~htuM{)r)GE2 z+&Q`X@N=X0YWuWtZH5<(TPmwxnO$DgZ@g~viz|&@;7Na|uR5CML#}@XSyh>CW*qA- zrL)qz>3%`KD>W`@f_LAnY?EJAP~VK$P~n%25c&$&zd>gKo!_pFZoc*ZfO?eNe;(Pl AumAu6 literal 0 HcmV?d00001 diff --git a/application/auth/__pycache__/models.cpython-312.pyc b/application/auth/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4a61f2a692d895c650052da498abc4b7fd6ee796 GIT binary patch literal 844 zcmbtSzi-n(6uz?^*GVXmB0!`PNDN4LL8vf<2r-l&4MRIX5yG-$Ik_Wsd;Zb0PsLl2 zIwVudLW&q*1SJC_{{mvoP@U9?sS831EKJ}&~$^SSq} za|HtMRg&q^55c4pgkqkkkjS53GXO{6FnY5AqM^Q1IF%7QC0j!8glq2f-E=`?voF2Rq zweFh=*ID3gFwBjB5#qK8HX)UrE}JE8I8NaD*l~Etar_W5BJnB5*S8-iT5Qw48@8E` zgCw>Wy`;%n_7mJ%!R=MsjUwW;-NXw6+hxhBE!1EVUyV{KmnbvxkH!y$*#>*XYPZ_2 z^=dowgT~9o`y1opwXKD{%K0wsr@eHywp)E$dtG~X{msRX+9x)y+}moN?7cj$)L%5| z*=dnwQ|IMlYV!We&xjkZJ0$FQ0hPPR3rkX9F7AvB&N7^nF5^}{%G-2KP`Lr|1!2Cc c5W;;hw+}A;&{cS|JKwMO>N`(=0ztCy-{C&LF8}}l literal 0 HcmV?d00001 diff --git a/application/auth/__pycache__/views.cpython-312.pyc b/application/auth/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5a28b608c495ba752f63db49849ce248789c573b GIT binary patch literal 1967 zcmZ`(O>7%Q6rR~#|NpGb#zdq=xXll>id=D^1QfLbK~k!wASD%Ov9z+ilX&A@JDr_v zh;gJGdT39rRHWvB1jnG{z>y<24qR+GDA6cYThR*_lq%)Ii8t$P5-DM%oqhA(H}l@S z_r3W&m5L)6zdihWUJfDjr&t67*8bSvh2LXjA`{!l!8&#%U2Pr)NoaVYDwF zpUs#VHxu*HW^zO7>&?_%v~d8@wg1_b-oSkbNto&p{&3&Ga;A{|OF#-C9{bq#$Rf2G zjH{G1OhOGtoJG6L2#-=?T9i~7k9gEJ=9-j;=IpXtD`2kNatVch>_&6mYD_k%Q;>Pu z77K%t+aByQdAz^&0Ll{}H$7&E1?#k`)L;Sb zZHTTFzT_Xu<*83+x$?#5GqZq-IE2-jrdvJ8jsFwX6dB%cLp~lOc90cxn86jO;tFn~ zg@ZaA-yCF%J_5UP+|rj9!Y6er5@4ez^`~NG=JQaX7m}y!QBUgH(k2dSyO2F;4`NFsV!0!1-~l5x7--oWfn-X7J^0TcQ(nRB%ppQ)qc+|Q1?-+d zh44+NQB+jEQFcfx@&%GYy~n z15B&vMRw@Xnbqq%sTplJysb`j)rp>Z<(~39p>7Sly_3v5n7%)~HvUSMa`9JTlp1`v}K z_5*?)HlBG%Y|x6N`h!IR=``9Ez9}eFbQTq- z9M$$GM9&LF9wr{{2TsReF$|w8Osfd85X#)0-c@3q__;0R{BA<~Zfb3+H!#vmjCPb! z|Ad=`T>m|+Q*jTUGe>TGuYB-WwTq(KMW<;J+wD{G^%GXXG`G+0gm`M}MxPVnt>|-9 z+=yqF2(7n>2Q5UZ9<|uA&te`m4AEhR!PCN-Q8|3vLlo*md~W%drK94+qeMg}ATZA+ zSLh`$h^Ny17N$KJWBe3N{(&a{2_sy1g5G(Gu6EJYC+OYh*`c+|KaT(M^;Y(?)%0E* zNttb&>*CzQ+IsHi@VeT;xgH*WDP{3A-j|W|!JaSfT{uEoJ)Gac>Ptz+V*-*9)47)l IEdAjA1M*A8cK`qY literal 0 HcmV?d00001 diff --git a/application/auth/forms.py b/application/auth/forms.py new file mode 100644 index 0000000..15e55b6 --- /dev/null +++ b/application/auth/forms.py @@ -0,0 +1,8 @@ +from flask_wtf import FlaskForm # type: ignore +from wtforms import StringField, SubmitField, PasswordField, validators + + +class LoginForm(FlaskForm): + username = StringField("Username", validators=[validators.DataRequired()]) + password = PasswordField("Password") + submit = SubmitField("Login") diff --git a/application/auth/models.py b/application/auth/models.py new file mode 100644 index 0000000..67dcf1a --- /dev/null +++ b/application/auth/models.py @@ -0,0 +1,8 @@ +from application import db +from flask_login import UserMixin # type: ignore + + +class User(db.Model, UserMixin): + id = db.Column(db.Integer, primary_key=True) + username = db.Column(db.String(150), unique=True, nullable=False) + password = db.Column(db.String(150), nullable=False) diff --git a/application/auth/templates/login.html b/application/auth/templates/login.html new file mode 100644 index 0000000..9a51dc2 --- /dev/null +++ b/application/auth/templates/login.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} + +{% block title %} +Login +{% endblock %} + +{% block content %} +{% if feedback %} +

{{feedback}}

+{% endif %} + + + {{ form.hidden_tag() }} + {{ form.username.label }} {{ form.username() }}
+ {{ form.password.label }} {{ form.password() }}
+ {{ form.submit() }} + +{% endblock %} \ No newline at end of file diff --git a/application/auth/views.py b/application/auth/views.py new file mode 100644 index 0000000..6fa467b --- /dev/null +++ b/application/auth/views.py @@ -0,0 +1,40 @@ +from flask import Blueprint, render_template, redirect, url_for, flash + +# from application import db +from application.auth.models import User +from application.auth.forms import LoginForm +from flask_login import login_required, login_user, logout_user # type: ignore +from werkzeug.security import check_password_hash + +auth_blueprint = Blueprint("auth", __name__, template_folder="templates") + +# Routes + + +@auth_blueprint.route("/login", methods=["GET", "POST"]) +def login(): + login_form = LoginForm() + feedback = None + + if login_form.validate_on_submit(): # type: ignore + username = login_form.username.data + password = login_form.password.data + user = User.query.filter_by(username=username).first() # type: ignore + + if user and check_password_hash( + user.password, password # type: ignore + ): + login_user(user) # type: ignore + return redirect(url_for("staking.strikers")) + else: + feedback = "Foutieve login." + + return render_template("login.html", form=login_form, feedback=feedback) + + +@auth_blueprint.route("/logout") +@login_required +def logout(): + logout_user() + flash("Je bent nu uitgelogd.") + return redirect(url_for("index")) diff --git a/application/templates/base.html b/application/templates/base.html new file mode 100644 index 0000000..3d081ec --- /dev/null +++ b/application/templates/base.html @@ -0,0 +1,41 @@ + + + + + + + {% block title %}{% endblock %} + + + + + + + +
+ {% block content %} + {% endblock %} +
+ + + + \ No newline at end of file diff --git a/application/templates/home.html b/application/templates/home.html new file mode 100644 index 0000000..c602bf9 --- /dev/null +++ b/application/templates/home.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block title %} +Staak-app +{% endblock %} + +{% block content %} +

Welkom bij de staak-app!

+{% endblock %} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c152f85..ca53bb7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,19 @@ +alembic==1.15.2 blinker==1.9.0 click==8.1.8 colorama==0.4.6 Flask==3.1.0 Flask-Login==0.6.3 +Flask-Migrate==4.1.0 +Flask-SQLAlchemy==3.1.1 Flask-WTF==1.2.2 +greenlet==3.1.1 itsdangerous==2.2.0 Jinja2==3.1.6 +Mako==1.3.9 MarkupSafe==3.0.2 pillow==11.1.0 +SQLAlchemy==2.0.40 +typing_extensions==4.13.0 Werkzeug==3.1.3 WTForms==3.2.1 From 97e4b7fe0aa12df2e48ea1fe4f724148266a4767 Mon Sep 17 00:00:00 2001 From: DaanoGames Date: Thu, 3 Apr 2025 15:55:50 +0200 Subject: [PATCH 17/70] base updated with navbar --- __pycache__/forms.cpython-312.pyc | Bin 880 -> 863 bytes templates/base_template.html | 36 ++++++++++++++++++++++++++++-- templates/dashboard.html | 3 +++ templates/navbar_base.html | 5 ----- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/__pycache__/forms.cpython-312.pyc b/__pycache__/forms.cpython-312.pyc index 644cca52201c439879baa6379515818b84bcad7a..b1d7f6603e94bdb4ada98dd8144c3002c25d9397 100644 GIT binary patch delta 44 zcmeyscAt&wG%qg~0}xE#y^-r8Bd>h2Rg6bsURA1lW=Y28pNxi#jK3ypGrIx+HG2*_ delta 61 zcmcc5_JNJ-G%qg~0}vGL*vNH}QO+RQDkiizwWv6zxFo5xJjNwIximL5ucSD}J+s7P P^9x2pM#fu{rI=j-adi~x diff --git a/templates/base_template.html b/templates/base_template.html index fa039f9..ae92dc5 100644 --- a/templates/base_template.html +++ b/templates/base_template.html @@ -4,12 +4,44 @@ + - {% block title %}{% endblock title %} + {% block title %}{% endblock %} + {% block content %} - {% include "navbar_base.html" %} {% endblock %} \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html index dcbc352..2df002f 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -3,5 +3,8 @@ {%block title%}Dashboard{%endblock%} {%block content%} +
+ Box +

The dashboard will display here

{%endblock%} \ No newline at end of file diff --git a/templates/navbar_base.html b/templates/navbar_base.html index 14e02c8..e69de29 100644 --- a/templates/navbar_base.html +++ b/templates/navbar_base.html @@ -1,5 +0,0 @@ - From 1a59cc415346c41bbe0feb6e2128a2a82578ec36 Mon Sep 17 00:00:00 2001 From: Stef Date: Sat, 12 Apr 2025 12:26:02 +0200 Subject: [PATCH 18/70] IDK 1234 --- .gitignore | 8 ++++ app.py | 9 +++- application/__init__.py | 5 +-- application/auth/views.py | 2 +- application/dash/forms.py | 9 ++++ application/dash/models.py | 7 ++++ application/dash/templates/dash.html | 0 application/dash/views.py | 61 ++++++++++++++++++++++++++++ application/templates/base.html | 1 - application/templates/home.html | 4 +- forms.py | 4 -- run.py | 1 + 12 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 application/dash/forms.py create mode 100644 application/dash/models.py create mode 100644 application/dash/templates/dash.html create mode 100644 application/dash/views.py diff --git a/.gitignore b/.gitignore index f7275bb..691eef1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,9 @@ +# venv's venv/ + +# DB stuff +migrations/ +instance/ + +# Byte-compiled / optimized / DLL files +__pycache__/ \ No newline at end of file diff --git a/app.py b/app.py index d5f03e8..06cdc0e 100644 --- a/app.py +++ b/app.py @@ -1,11 +1,16 @@ from application import app -from flask import render_template +from flask import redirect, url_for +from flask_login import current_user, login_required # home route @app.route("/") +@login_required def index(): - return render_template("home.html") + if current_user.is_authenticated: + return redirect(url_for("application.dash")) + else: + return redirect(url_for("application.auth")) # App deployment diff --git a/application/__init__.py b/application/__init__.py index 8bb7f47..b3b5ada 100644 --- a/application/__init__.py +++ b/application/__init__.py @@ -17,8 +17,7 @@ migrate = Migrate(app, db) # bp import from application.auth.views import auth_blueprint - -# from application.strike.views import strike_blueprint +from application.dash.views import dash_blueprint # Login manager from application.auth.models import User @@ -35,5 +34,5 @@ def load_user(user_id): # type: ignore # Blueprint magic -# app.register_blueprint(strike_blueprint, url_prefix="/staking") +app.register_blueprint(dash_blueprint, url_prefix="/dash") app.register_blueprint(auth_blueprint, url_prefix="/auth") diff --git a/application/auth/views.py b/application/auth/views.py index 6fa467b..55b9b06 100644 --- a/application/auth/views.py +++ b/application/auth/views.py @@ -25,7 +25,7 @@ def login(): user.password, password # type: ignore ): login_user(user) # type: ignore - return redirect(url_for("staking.strikers")) + return redirect(url_for("application.dash")) else: feedback = "Foutieve login." diff --git a/application/dash/forms.py b/application/dash/forms.py new file mode 100644 index 0000000..57d8c19 --- /dev/null +++ b/application/dash/forms.py @@ -0,0 +1,9 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, SubmitField, URLField +from wtforms.validators import DataRequired + + +class ServiceForm(FlaskForm): + name = StringField("Service name:", validators=[DataRequired()]) + url = URLField("Service URL:", validators=[DataRequired()]) + submit = SubmitField("Add") diff --git a/application/dash/models.py b/application/dash/models.py new file mode 100644 index 0000000..b468005 --- /dev/null +++ b/application/dash/models.py @@ -0,0 +1,7 @@ +from application import db + + +class Service(db.Model): + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String, nullable=False) + url = db.Column(db.String, nullable=False) diff --git a/application/dash/templates/dash.html b/application/dash/templates/dash.html new file mode 100644 index 0000000..e69de29 diff --git a/application/dash/views.py b/application/dash/views.py new file mode 100644 index 0000000..4acb3be --- /dev/null +++ b/application/dash/views.py @@ -0,0 +1,61 @@ +from flask import ( + Blueprint, + render_template, + redirect, + url_for, + request, + flash, + session, + get_flashed_messages, +) +from application import db +from application.dash.models import Service +from application.dash.forms import ServiceForm +from flask_login import login_required, current_user + +dash_blueprint = Blueprint("dash", __name__, template_folder="templates") + +# Routes + +""" +@strike_blueprint.route("/bedankt", methods=["GET"]) +def thanks(): + return render_template("bedankt.html") +""" + + +@dash_blueprint.route("/", methods=["GET", "POST"]) +@login_required +def index(): + session["_flashes"] = [] + my_form = ServiceForm() + + if request.method == "POST": + if my_form.validate_on_submit(): + flash("Het formulier is succesvol gePOST") + + session["naam"] = my_form.name.data + session["url"] = my_form.url.data + flash("De gegevens zijn in de sessie opgeslagen") + + new_service = Service(name=my_form.name.data, url=my_form.url.data) + db.session.add(new_service) + db.session.commit() + flash("De gegevens zijn in de database opgeslagen") + + return redirect(url_for("application.dash")) + else: + flash("Het formulier is niet goed ingevuld") + + return render_template("dash.html", form=my_form) + + +""" +@strike_blueprint.route("/stakers") +@login_required +def strikers(): + rows = Striker.query.all() + return render_template( + "strikers.html", rows=rows, user=current_user.username + ) +""" diff --git a/application/templates/base.html b/application/templates/base.html index 3d081ec..731836a 100644 --- a/application/templates/base.html +++ b/application/templates/base.html @@ -7,7 +7,6 @@ {% block title %}{% endblock %} - diff --git a/application/templates/home.html b/application/templates/home.html index c602bf9..1c60278 100644 --- a/application/templates/home.html +++ b/application/templates/home.html @@ -1,9 +1,9 @@ {% extends 'base.html' %} {% block title %} -Staak-app +Idk applicatie {% endblock %} {% block content %} -

Welkom bij de staak-app!

+

Dit is de home page, hopelijk redirect de pagina

{% endblock %} \ No newline at end of file diff --git a/forms.py b/forms.py index 5e1e169..57d8c19 100644 --- a/forms.py +++ b/forms.py @@ -7,7 +7,3 @@ class ServiceForm(FlaskForm): name = StringField("Service name:", validators=[DataRequired()]) url = URLField("Service URL:", validators=[DataRequired()]) submit = SubmitField("Add") - - -class LoginForm(FlaskForm): - pass diff --git a/run.py b/run.py index 7ae4511..a29d891 100644 --- a/run.py +++ b/run.py @@ -12,6 +12,7 @@ def index(): # Return HTML content return "

This is the default page

" + @app.route("/dashboard") def dashboard(): # Return Dashboard.html From 79da565ea301155b4091e3bba975b09e796edf4f Mon Sep 17 00:00:00 2001 From: Stef Date: Sat, 12 Apr 2025 12:59:15 +0200 Subject: [PATCH 19/70] 123123123 --- app.py | 5 ++--- application/auth/views.py | 2 +- seed.py | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 seed.py diff --git a/app.py b/app.py index 06cdc0e..85dcb01 100644 --- a/app.py +++ b/app.py @@ -5,12 +5,11 @@ from flask_login import current_user, login_required # home route @app.route("/") -@login_required def index(): if current_user.is_authenticated: - return redirect(url_for("application.dash")) + return redirect(url_for("dash.index")) else: - return redirect(url_for("application.auth")) + return redirect(url_for("auth.login")) # App deployment diff --git a/application/auth/views.py b/application/auth/views.py index 55b9b06..57a7068 100644 --- a/application/auth/views.py +++ b/application/auth/views.py @@ -25,7 +25,7 @@ def login(): user.password, password # type: ignore ): login_user(user) # type: ignore - return redirect(url_for("application.dash")) + return redirect("/") else: feedback = "Foutieve login." diff --git a/seed.py b/seed.py new file mode 100644 index 0000000..8ff1189 --- /dev/null +++ b/seed.py @@ -0,0 +1,24 @@ +from application import db, app +from application.dash.models import Service +from application.auth.models import User +from werkzeug.security import generate_password_hash + +""" +new_strikers = [ + se(name="Erik", strike="y", age=44), + Striker(name="Henk", strike="n", age=88), +] + +""" + +new_user = User(username="admin", password=generate_password_hash("admin")) + +with app.app_context(): + # Remove all existing + Service.query.delete() + User.query.delete() + db.session.commit() + # Then add new + # db.session.add_all(new_strikers) + db.session.add(new_user) + db.session.commit() From 8055a7fb713079c82d2a91e5759eb7ccc0a2f789 Mon Sep 17 00:00:00 2001 From: DaanoGames Date: Sat, 12 Apr 2025 12:59:33 +0200 Subject: [PATCH 20/70] added css --- static/style.css | 22 ++++++++++++++++++++++ templates/base_template.html | 16 ++++++++-------- templates/dashboard.html | 22 +++++++++++++++++++--- 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 static/style.css diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..b912c98 --- /dev/null +++ b/static/style.css @@ -0,0 +1,22 @@ +body { + background-color: lightslategray; +} + +.grid-container { + display: grid; + grid-template-columns: auto auto auto; + gap: 20px; + background-color: lightslategray; + padding-top: 20px; + margin-left: 10%; + margin-right: 10%; +} + +.grid-container > div { + text-align: center; + height: 100px; + padding-top: 5px; + border: 2px solid black; + border-radius: 10px; + background-color: whitesmoke; +} \ No newline at end of file diff --git a/templates/base_template.html b/templates/base_template.html index ae92dc5..ba26656 100644 --- a/templates/base_template.html +++ b/templates/base_template.html @@ -4,24 +4,24 @@ - + {% block title %}{% endblock %} -