From 2884645c5e009fecdc08a2b98677e6042f0b9b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Sat, 16 Sep 2023 21:54:04 -0600 Subject: [PATCH 1/9] . --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index d82c51f0d..8dea1d625 100644 --- a/app.py +++ b/app.py @@ -3,4 +3,4 @@ @app.route('/') def hello_world(): - return 'Hello, World!' + return 'Holla Kelvin' From 90a27c9d2636320b1fe021148bb513e9fec7be88 Mon Sep 17 00:00:00 2001 From: Orrv2904 Date: Thu, 21 Sep 2023 11:12:10 -0600 Subject: [PATCH 2/9] :construction: --- .env.templates | 3 +++ app.py | 6 ------ application.py | 36 ++++++++++++++++++++++++++++++++++++ crear_tablas.py | 18 ++++++++++++++++++ models.py | 11 +++++++++++ requirements.txt | Bin 15 -> 592 bytes templates/estudiantes.html | 26 ++++++++++++++++++++++++++ templates/index.html | 37 +++++++++++++++++++++++++++++++++++++ 8 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 .env.templates delete mode 100644 app.py create mode 100644 application.py create mode 100644 crear_tablas.py create mode 100644 models.py create mode 100644 templates/estudiantes.html create mode 100644 templates/index.html diff --git a/.env.templates b/.env.templates new file mode 100644 index 000000000..e76fd68cd --- /dev/null +++ b/.env.templates @@ -0,0 +1,3 @@ +FLASK_APP=application.py +FLASK_DEBUG=1 +DATABASE_URL= \ No newline at end of file diff --git a/app.py b/app.py deleted file mode 100644 index 8dea1d625..000000000 --- a/app.py +++ /dev/null @@ -1,6 +0,0 @@ -from flask import Flask -app = Flask(__name__) - -@app.route('/') -def hello_world(): - return 'Holla Kelvin' diff --git a/application.py b/application.py new file mode 100644 index 000000000..6aef17fbd --- /dev/null +++ b/application.py @@ -0,0 +1,36 @@ +import os +from flask import Flask, request, render_template, redirect, url_for +from dotenv import load_dotenv +from models import db, Estudiantes +load_dotenv() + +app = Flask(__name__) +app.config['SECRET_KEY'] = 'mysecretkey' + +if not os.getenv("DATABASE_URL"): + raise RuntimeError("DATABASE_URL is not set") +app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL') +db.init_app(app) + +@app.route('/') +def lista_estudiantes(): + estudiantes = Estudiantes.query.all() + return render_template('estudiantes.html', estudiantes=estudiantes) + + +@app.route('/Crear', methods=['GET', 'POST']) +def nuevo_estudiante(): + if request.method == 'POST': + nombre = request.form.get('Nombre') + apellido = request.form.get('Apellido') + ciclo = request.form.get('Ciclo') + programa = request.form.get('Programa') + + if nombre and apellido and ciclo and programa: + nuevo_estudiante = Estudiantes(nombre=nombre, apellido=apellido, ciclo=ciclo, programa=programa) + db.session.add(nuevo_estudiante) + db.session.commit() + + return redirect(url_for('lista_estudiantes')) + + return render_template('index.html') diff --git a/crear_tablas.py b/crear_tablas.py new file mode 100644 index 000000000..b8c978bc7 --- /dev/null +++ b/crear_tablas.py @@ -0,0 +1,18 @@ +import os +from flask import Flask +from flask_sqlalchemy import SQLAlchemy +from models import * +from dotenv import load_dotenv +load_dotenv() + +app = Flask(__name__) +app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URL") +app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False +db.init_app(app) + +def main(): + db.create_all() + +if __name__ == "__main__": + with app.app_context(): + main() \ No newline at end of file diff --git a/models.py b/models.py new file mode 100644 index 000000000..ae2fddfe9 --- /dev/null +++ b/models.py @@ -0,0 +1,11 @@ +from flask_sqlalchemy import SQLAlchemy + +db = SQLAlchemy() + +class Estudiantes(db.Model): + __tablename__ = "Estudiantes" + id = db.Column(db.Integer, primary_key=True) + nombre = db.Column(db.String, nullable=False) + apellido = db.Column(db.String, nullable=False) + ciclo = db.Column(db.String, nullable=False) + programa = db.Column(db.String, nullable=False) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 147ddd086cbf61be38d50f00dbde920d4ffd9742..73148504427d8c521c3ec261e05e139e95d247d9 100644 GIT binary patch literal 592 zcmZ`$O;5r=6r3}OKLrBC03JMe@nGaYIB+zj)>4sn(+>mucy;EzMZB2irRkg5nd$8J z*A^crQDKi94et3&Fv5(J;06O^hG)cuEw~pxk62B#=D8FHju>O2x15gtVdw}6mQh}t1-3Afr#2m>7|~F z$Z;*X1bUw=aUkkW%5lf>o&)iYz0^EEWb&F{YT?tglvfRm&F{Y^uRVE}9W_Ht^g^{` d)NHwvkN2UQ)SbKb#@gEB%y<9$Cw`}%^auXgR_Oo$ literal 15 WcmZ?ENi5FhaxcxxOwKRL;{pIG + + + + + + + Document + + + + + {% for estudiante in estudiantes %} +
+
  • Nombre: {{ estudiante.nombre }} {{ estudiante.apellido }} - Ciclo: {{ estudiante.ciclo }} - Programa: {{ + estudiante.programa }}
  • +
    + {% endfor %} + + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 000000000..9224b4a8c --- /dev/null +++ b/templates/index.html @@ -0,0 +1,37 @@ + + + + + + + + Document + + + + +
    +
    + + + + + + + + + + + + + +
    +
    + + + \ No newline at end of file From 2eb20ed1811fc3cf12aa16fd7422a22fdbf21fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Fri, 22 Sep 2023 10:54:10 -0600 Subject: [PATCH 3/9] . --- requirements.txt | Bin 592 -> 366 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index 73148504427d8c521c3ec261e05e139e95d247d9..97c5ce230e367ae598f4a3ddce74de2069ef4112 100644 GIT binary patch literal 366 zcmZ{fy$*sf6ot=h;-j$m1}+Xp2jk#q5D^ij4N#*#y!zeJ#L19`o}YW}>F0gWRkd0* zD%EMKiHgV+Fe7qchnDNcF>V2qt51#}%Cyx+E6vdhok_gu87C^{OTHGR)R4FUu5ns= z8@U>-*OByA70wPVz}VJh?0G?(MZD(L(ILpQH`fWj`8;=PpOauOs}kGO#ddj^F~P$O o^mMo~wmOh?yvK=uZyA{KDS40ok*0b$OB&nmV*5rf{vmbv0+BjD*8l(j literal 592 zcmZ`$O;5r=6r3}OKLrBC03JMe@nGaYIB+zj)>4sn(+>mucy;EzMZB2irRkg5nd$8J z*A^crQDKi94et3&Fv5(J;06O^hG)cuEw~pxk62B#=D8FHju>O2x15gtVdw}6mQh}t1-3Afr#2m>7|~F z$Z;*X1bUw=aUkkW%5lf>o&)iYz0^EEWb&F{YT?tglvfRm&F{Y^uRVE}9W_Ht^g^{` d)NHwvkN2UQ)SbKb#@gEB%y<9$Cw`}%^auXgR_Oo$ From 0362d166a7749c1e24734c88d2bd1bfd38e546e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Fri, 22 Sep 2023 10:56:18 -0600 Subject: [PATCH 4/9] . --- requirements.txt | Bin 366 -> 592 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index 97c5ce230e367ae598f4a3ddce74de2069ef4112..ff9cc739e3615b42261c697f743c44921903427a 100644 GIT binary patch literal 592 zcmZ{hJ5R$<6oWk@@l#s$0R;vI76t?ZVqioel(dv4Q67l$qbSF|wy*Q` z`KVW|RcfQ98lCe@HP(We=}-sC1JA*Yow7H6GGG;G#kovd#*7K*5wi%!C3vQGI6Y&3 z9Ao7@HqxDLb*&57xmG0EY8PsA*!G)-T7lD&r-Zju7Yu9KGo>xmgRW6=s&ZghA@S_H z=47iUa+NC3Y2fy3oZhU&HuEZ)d4V|#^e0X7x?$gNvtBj%Gd-jAS7RQTYY?}W;pLu- zfs?fCQscdg#5HJga*i`5^<0B@^ipwtMDmI+x9}EP&g%vy;rCyY`<_yl9h&u!=mE9& fL9=CNpVWu{r2l!+zK^yx`rzIF-efG_B_;g^23S_@ literal 366 zcmZ{fy$*sf6ot=h;-j$m1}+Xp2jk#q5D^ij4N#*#y!zeJ#L19`o}YW}>F0gWRkd0* zD%EMKiHgV+Fe7qchnDNcF>V2qt51#}%Cyx+E6vdhok_gu87C^{OTHGR)R4FUu5ns= z8@U>-*OByA70wPVz}VJh?0G?(MZD(L(ILpQH`fWj`8;=PpOauOs}kGO#ddj^F~P$O o^mMo~wmOh?yvK=uZyA{KDS40ok*0b$OB&nmV*5rf{vmbv0+BjD*8l(j From c2bdcda447b8e43deebc4dfd4e0576cd4d2f9b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Fri, 22 Sep 2023 10:58:22 -0600 Subject: [PATCH 5/9] . --- requirements.txt | Bin 592 -> 592 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index ff9cc739e3615b42261c697f743c44921903427a..319708568cb406cc91bc40ddb0ebf17dc85cb68d 100644 GIT binary patch delta 12 Tcmcb>a)D(+5u?$@;=7ChAhHDD delta 12 Tcmcb>a)D(+5u@qG;=7ChAi)IV From 42dc1941764d9d683bad33c4e0a7b9f649879449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Fri, 22 Sep 2023 10:59:32 -0600 Subject: [PATCH 6/9] . --- requirements.txt | Bin 592 -> 592 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index 319708568cb406cc91bc40ddb0ebf17dc85cb68d..ace37fc16fb0398cbb771931eebe03ad3d96810a 100644 GIT binary patch delta 16 Ycmcb>a)D*S5>^8SJqFW_E0;3@05InTcK`qY delta 16 Ycmcb>a)D*S5>`V7JqE*#E0;3@05IGIbN~PV From da48c4aba1b7fce231c6bbd4f052ce0f927a997a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Fri, 22 Sep 2023 11:00:12 -0600 Subject: [PATCH 7/9] . --- requirements.txt | Bin 592 -> 596 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index ace37fc16fb0398cbb771931eebe03ad3d96810a..63a22ebda46af51b7c97f13cfb88053a9e2bf42f 100644 GIT binary patch delta 25 ecmcb>a)o8X5k_7E20aEN216hT#FNi5HUj`!ga%;% delta 21 acmcb@a)D*T5k^i!20aD?5T1OIu^9kIn+5;? From b9d0361e3d8f1e8467ae504badef06857ebbaeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Fri, 22 Sep 2023 11:01:31 -0600 Subject: [PATCH 8/9] :construction: --- requirements.txt | Bin 596 -> 596 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index 63a22ebda46af51b7c97f13cfb88053a9e2bf42f..4f2914fbab3fb810241e91e633f0c7c59cc85afb 100644 GIT binary patch delta 17 Ycmcb@a)o7s1{13}gC2w7WL+k804+rX4*&oF delta 17 Ycmcb@a)o7s1{13VgC2vyWL+k804+%b4*&oF From 649bfca190fd90ce2be6dc1e8469c9f8521fa29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Rodr=C3=ADguez?= Date: Fri, 22 Sep 2023 11:02:49 -0600 Subject: [PATCH 9/9] :construction: --- requirements.txt | Bin 596 -> 596 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4f2914fbab3fb810241e91e633f0c7c59cc85afb..d0a5ad093fcb5568cea17818d9632c7b88ea2b79 100644 GIT binary patch delta 18 Zcmcb@a)o7s7ZaBegC2u111|#?0{}0817QFF delta 18 Zcmcb@a)o7s7ZaB;gC2u911|#?0{}0g17-jK