From 3cb605fcb32d624fc76ff73fb1824f8db77cfb40 Mon Sep 17 00:00:00 2001 From: Ari Bermeki Date: Sun, 20 Mar 2022 19:26:33 +0100 Subject: [PATCH] first-commit --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 5 + Procfile | 1 + __pycache__/app.cpython-39.pyc | Bin 0 -> 3110 bytes __pycache__/config.cpython-39.pyc | Bin 0 -> 1124 bytes __pycache__/data_cfg.cpython-39.pyc | Bin 0 -> 316 bytes __pycache__/yaml_data_cfg.cpython-39.pyc | Bin 0 -> 321 bytes app.py | 112 +++++++++++++++++++++++ config.py | 27 ++++++ requirements.txt | 23 +++++ run.py | 6 ++ static/.DS_Store | Bin 0 -> 6148 bytes templates/base.html | 15 +++ templates/index.html | 21 +++++ templates/log.html | 31 +++++++ templates/office.html | 16 ++++ templates/regester.html | 59 ++++++++++++ yaml_data_cfg.py | 5 + 18 files changed, 321 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 Procfile create mode 100644 __pycache__/app.cpython-39.pyc create mode 100644 __pycache__/config.cpython-39.pyc create mode 100644 __pycache__/data_cfg.cpython-39.pyc create mode 100644 __pycache__/yaml_data_cfg.cpython-39.pyc create mode 100644 app.py create mode 100644 config.py create mode 100644 requirements.txt create mode 100644 run.py create mode 100644 static/.DS_Store create mode 100644 templates/base.html create mode 100644 templates/index.html create mode 100644 templates/log.html create mode 100644 templates/office.html create mode 100644 templates/regester.html create mode 100644 yaml_data_cfg.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7662a0903f585e127302e585ccbb727e8a311820 GIT binary patch literal 6148 zcmeHK%Z}496us`0PRa-=3y@}m6p3v$l$jAy#U_+t!46Rb3qU1l!VrN}6F?0rIV`k01Bg^@(H0L?nib=nj!fL=K#>eHFqGNhb3rbXOic&@es4VU@M>~Y`1S(@ZUzyDpd_S#oE`_8^|;Jg~W zmCI2P6pMTq%wKTnsg!BB$p_)HBwmi)>knjB1W6Xp6(NaYguHy7WRYABp-He0Khh?l_Afc0nG6X`UXplXn_e$ z1!}4=R}7))sP{~qZ?M#;=_JhMLzt0;xuFO(I{NoiI0;{)O|1e}fw}^Fy6E!x|M1WE z|2oN*tO8bn|4ISTJ{z44F(q@hHYUestp|S%XXCh1qoN=&$Fa)rQG5tjhBl8gK;K}g S5j8OTA)sWiiB({y3j6~8qPmm- literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..237b3bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +cfg.yaml +.env +venv +__pycashe__ +database.db \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..029b1e7 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn run:app \ No newline at end of file diff --git a/__pycache__/app.cpython-39.pyc b/__pycache__/app.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..542040a7cfc26dd35c69f2351836dc0fc7f9de76 GIT binary patch literal 3110 zcma)8OK%%D5GMDnm1N1X<2Y~CZPTb|tfmjNhoESiI6=@vbtAPvhyt6nNXe`0L*cHH z*icW-HP@c)qyI^N!(MyJUnqL$3|DsK#6>HDqj_+L!;ixu{c6=E@cTXaYHO`b$e$?8 z{|pemg`WOO3E_m(kVKTxNMl;0Gd(hxK~b-TW@IrdvY8z@%uzZ$EJZGJqcSTi*$699 zl~omQh6_=R)f8`q^=OeTD&7totO5Rl6fqal%S1E|{Y>PJ6g-fk zpXK&MhTb5NEj=%HGa1CgJAnu}2$QWS$O@sl>8I)QL~0BR?nbY7uXDExpKaWFxY6@|*m%^(Ma}j+jagFP*G-eB9 zALM=K0Jf2pPDt(vseD4J%=}cv!l=d#@Kom}w_Xyqs9<(-6Cb6ssW`_9jG=nfa;vUUeeB?k=xG_ z8T%1zT1B6gZwcRTE zTtBjRS`8eGA$nf!dR~<9Nr-&K^PW!pu&}VI=Vks@C}smSzQwFtNjQmOX5Wi5F%&Y_ z0uI=!q&#g^%()FY)Po$73lI;pCRsmDp0jda3NUz(VZKCs)#B&K1=KZwAd}XCIMkqZ zx-e@ELs{R+Hw#97i=Tu*j`B_DoC;%)2vcPng+q*)Vu2oV?j5}idTXY)Av=%8JEFv$ zQ}iw`K@zyR^AI3OGsrgkmm(KlW3@e`xgPm14k>e=`C$M{PGriQ&T*D(V3xf81BT|# z(JAh<%JLFub%0>i(kbcUG-|ULAJypTWhqM`2I3&aN9kS$?s;okigxl{#2Yn=3cfup*wiHuux*t;Cm{8Jjm^WtUNq9-@%@P4?1~cKVk~^$4 z2tqiH-qwzqHaD=``k(UxBT4jhO>{7D)uHICaNUG5dLjS&$YL5zBzYQ_C7N{ra0S`=(w(GN3~b#z=Vi z5>_kZt)usktf01DXw#>mUp$0l71X(wq{Rj1jMJTdG9G@$syluZste5P4~DV^!&Jov zfW~8dv-vSkBDsiO0j_uu3|V;~lgLZ9M(SB7;%9+O;sRguLBd5??8F-S!b-(VnM@#q zv6iUQQb3Ck&Eb1o=5yy}ag~1quXmDu0c4df!>w6S%>fGCbbz|FL0#Q38%uS!?t*O8 LscS)BtkZu0ZIG?@ literal 0 HcmV?d00001 diff --git a/__pycache__/config.cpython-39.pyc b/__pycache__/config.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c1968971051865a89f101ff67993efff4b528ad0 GIT binary patch literal 1124 zcmbVL%Wl&^6dk`}=LN1*gkZ@oi;^V^5NZ;;p;Br};~+5`%gIbq=V6-}w}>@-2cpY< z2tVO1D}I3$_f7(&wAnD$9NlwgH22(x<7Tr)V0~FU8-LRX`Hp0JSwIe9%N&3arY#92 zoXoYaxe$@X9BH+Q3a_0k^mf+yP!;HgH?`3GY~CrI)4C zWOfwNhSv!@-OkXDMrVVdRV|$;O5+ueqOul6tBhSN(QZW1`-^zFIk7yyJL;Eq=nuo= zpidjU;n`8-2c7P~_ewpJrOngJL}Y3CaQJ4>8T4NHC-0)IP{-Fq)IqI+pU>MP$%Smo zY+8JX1!w${FSDGBw#Vh7$ntg}vPH_pK@Q%7IM3S?mB7>dqrmL3FVX>UG*f-bd#g~; z(siL+Fm4n|hq4%@dnzE|Ns(mfra(c<6b4)tCIW^L6@)+9*H#04O#n0`DsnW%cT3oZ zOE)B_UMU&PVG+-gbhg$I2G`a<8fe|~-}-~srzd_8?iO?pLSUv6#badzdj3n&p0{qv zil@bIS>istc4s9p=mXe)1EXhm;2rH~hFlg~b-3LNdzXSeICzW-HoZXJY6u*W(#+%H zytL!7TpKJAIM+D&(*&oT+T&PqaF>;AJm-@_O_S=Us-Qr<0-wAq`_g%_{%v03xJjG{ ON82}C+cjOwwSECh2iDpE literal 0 HcmV?d00001 diff --git a/__pycache__/data_cfg.cpython-39.pyc b/__pycache__/data_cfg.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a6610961289b5fa93a9bc6cf0adab9a57b59db95 GIT binary patch literal 316 zcmYk0u};G<5J1m~(?k)Kx*~pn3?(qJKt)hNLaG=j6~aqp@D)Mb*w_iE9qEkt4t^;s z6TiU3r7WD~cRJtQlV!J?0>zFzynCbk)fWFFq2h$D9}yHNra=HQ6|C9Et_TpGLTt%Z z_#TJ|BgMBtbZ%&p1BZ3UpzIxhAM69$oLiz|W5}X!GQ#C5xt~4kE#*RItm%x5ROrOk zu(&Qxi}BfXa&?i#g17yK8;hj~rF(3+ra_UO*INIrG+fC_HnGR&8q3uuxR~r4{2b>K zkIv`b%&J%EP~i(|a=CnneqI@ySI*2!bbU*&eQ9mp%BJnd?6OIY7Dm+?2aJrqLr7T4 Gdh8d-Cr@Dj literal 0 HcmV?d00001 diff --git a/__pycache__/yaml_data_cfg.cpython-39.pyc b/__pycache__/yaml_data_cfg.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..724ae82decb3d5a812a7fdd919efe334128ba50b GIT binary patch literal 321 zcmYk0y-ve05P;8#^P`ALT@f!ph7y=qP(`YOgj6w5DukEF;46ZTI`RK@% z|L%zZ1I2eigf}$Ffy2gUQ1*|&4iABC^OmUC6w=_EjBvS*@8=H(E4kDu>%vJT6&kTK z&ad-PK0PaDR~Km{xI6E7Rbwf9X&yVSX;38Rt=4~6I<90RyU5~mi{<(gOhooAen#2M zqOqB+=FO`#sPF|fxlA@jyJ)I9YfQB$(F|(Z9mu-Q+=%3(QFs6V literal 0 HcmV?d00001 diff --git a/app.py b/app.py new file mode 100644 index 0000000..a52f9c2 --- /dev/null +++ b/app.py @@ -0,0 +1,112 @@ +from flask import Flask, render_template, redirect, url_for +from wtforms import StringField, SubmitField, PasswordField +from wtforms.validators import InputRequired, Length +from flask_wtf import FlaskForm +from flask_bootstrap import Bootstrap +from flask_sqlalchemy import SQLAlchemy +import os +from datetime import datetime +import psycopg2 +from yaml_data_cfg import sequenz + + + + +app = Flask(__name__) +Bootstrap(app) +SECRET_KEY = os.urandom(32) +app.config.from_object(os.environ['APP_SETTINGS']) +app.config['SECRET_KEY'] = SECRET_KEY +#app.config['SQLALCHEMY_DATABASE_URI'] = sequenz + +db = SQLAlchemy(app) + + + + +class User(db.Model): + __tablename__= 'SYSTEM' + id=db.Column( db.Integer, primary_key = True) + vorname = db.Column( db.String()) + nachname = db.Column(db.String()) + email = db.Column(db.String()) + password = db.Column(db.String()) + create_data = db.Column(db.DateTime, default=datetime.utcnow) + + + + def __init__(self, vorname, nachname, email, password): + self.vorname = vorname + self.nachname = nachname + self.email = email + self.password = password + + + +class Regester(FlaskForm): + vorname = StringField('Vorname', validators=[InputRequired(), Length(max=10)]) + nachname = StringField('Nachname', validators=[InputRequired(), Length(max=10)]) + email = StringField('Email', validators=[InputRequired(), Length(max=200)]) + password = PasswordField('Password', validators=[InputRequired(), Length(max=200)]) + + + + + +class Login(FlaskForm): + email = StringField('Email', validators=[InputRequired(), Length(max=200)]) + password = PasswordField('Password', validators=[InputRequired(), Length(max=200)]) + submit = SubmitField('Regester') + + + + + + +@app.route('/') +def index(): + return render_template('index.html') + + +@app.route('/dashboard', methods=['POST', 'GET']) +def office(): + return render_template('office.html') + + + + +@app.route('/log', methods=['POST', 'GET']) +def user(): + form = Login() + if form.validate_on_submit(): + user = User.query.filter_by(email=form.email.data).first() + password = User.query.filter_by(password=form.password.data).first() + if user: + if password: + return redirect(url_for('office')) + else: + return '

The user is not exested

' + + return render_template('log.html', form=form) + + + + + +@app.route('/regester', methods=['POST', 'GET']) +def regist(): + form = Regester() + if form.validate_on_submit(): + user = User( + vorname = form.vorname.data, + nachname = form.nachname.data, + email= form.email.data, + password = form.password.data + ) + db.session.add(user) + db.session.commit() + + return redirect(url_for('user')) + + return render_template('regester.html', form=form) + diff --git a/config.py b/config.py new file mode 100644 index 0000000..81ddc0b --- /dev/null +++ b/config.py @@ -0,0 +1,27 @@ +import os +basedir = os.path.abspath(os.path.dirname(__file__)) + + +class Config(object): + DEBUG = False + TESTING = False + CSRF_ENABLED = True + SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL'] + + +class ProductionConfig(Config): + DEBUG = False + + +class StagingConfig(Config): + DEVELOPMENT = True + DEBUG = True + + +class DevelopmentConfig(Config): + DEVELOPMENT = True + DEBUG = True + + +class TestingConfig(Config): + TESTING = True \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4840ed0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,23 @@ +bcrypt==3.2.0 +cffi==1.15.0 +click==8.0.4 +dominate==2.6.0 +Flask==2.0.3 +Flask-Bcrypt==0.7.1 +Flask-Bootstrap==3.3.7.1 +Flask-Login==0.5.0 +Flask-SQLAlchemy==2.5.1 +Flask-WTF==1.0.0 +gunicorn==20.1.0 +itsdangerous==2.1.1 +Jinja2==3.0.3 +MarkupSafe==2.1.1 +psycopg2==2.9.3 +pycparser==2.21 +PyYAML==6.0 +six==1.16.0 +SQLAlchemy==1.4.32 +visitor==0.1.3 +Werkzeug==2.0.3 +WTForms==3.0.1 +python-dotenv==0.19.2 \ No newline at end of file diff --git a/run.py b/run.py new file mode 100644 index 0000000..380b815 --- /dev/null +++ b/run.py @@ -0,0 +1,6 @@ +from app import app + + + +if __name__=="__main__": + app.run(debug=True) \ No newline at end of file diff --git a/static/.DS_Store b/static/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a2ea73c603c618044b092f338720885af11f4fa7 GIT binary patch literal 6148 zcmeHKu};H447J+|1z0*VW@7Ijgeo1FGb5p<5+J2YL}AYl@I97=`2Q}q%Nf%VnRkt>N#lAPK+B&%d6?Wq7IuB27U#!kAIiJ;T%NeM-MT!rd0cXG& z_{9w1&K8OG72P@m&VVz}Fd*ND7%G?;){5cN0TWsP-~{d<7>A#KU@Q(`VpuD}17TeX z)TL}K23zmIx*YMu@@qw1P8^<$eeB6>9SU3P!Es0@P88ib1I|E~fw4}fa{n*3_y65R zK63_~fq%sSPtq)% + + + + + + {% block title %}{% endblock %} + + + + + {% block body %}{% endblock %} + + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..696d495 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% import "bootstrap/wtf.html" as wtf %} +{{ wtf.quick_form(form) }} + + + +{% block head %} + + +{% endblock %} + + + +{% block body %} +
+

Hallo von Homepage

+ Logn in + Sign Up +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/log.html b/templates/log.html new file mode 100644 index 0000000..e9b5b56 --- /dev/null +++ b/templates/log.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% import "bootstrap/wtf.html" as wtf %} +{{ wtf.quick_form(form) }} + + + +{% block head %} + + +{% endblock %} + + + +{% block body %} + +
+ + {{ form.hidden_tag() }} + {{wtf.form_field(form.email)}} + {{wtf.form_field(form.password)}} + + + + +
+ + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/office.html b/templates/office.html new file mode 100644 index 0000000..3fc06db --- /dev/null +++ b/templates/office.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% import "bootstrap/wtf.html" as wtf %} +{{ wtf.quick_form(form) }} + + + +{% block head %} + + +{% endblock %} + + + +{% block body %} +

Hallo von Office

+{% endblock %} \ No newline at end of file diff --git a/templates/regester.html b/templates/regester.html new file mode 100644 index 0000000..c60ce68 --- /dev/null +++ b/templates/regester.html @@ -0,0 +1,59 @@ +{% extends "base.html" %} +{% import "bootstrap/wtf.html" as wtf %} +{{ wtf.quick_form(form) }} + +{% block head %} + + +{% endblock %} + + + +{% block body %} +{% block content %} +
+ + + + {% for message in get_flashed_messages() %} +
+ + {{ message }} +
+ {% endfor %} + +

Sign Up

+ +{% endblock %} +
+ + + + + {{ form.hidden_tag() }} + {{wtf.form_field(form.vorname)}} + {{wtf.form_field(form.nachname)}} + {{wtf.form_field(form.email)}} + {{wtf.form_field(form.password)}} + + + + + +
+ + + + + +{% endblock %} \ No newline at end of file diff --git a/yaml_data_cfg.py b/yaml_data_cfg.py new file mode 100644 index 0000000..6f1a8ca --- /dev/null +++ b/yaml_data_cfg.py @@ -0,0 +1,5 @@ +import yaml +with open('cfg.yaml') as ari: + data = yaml.load(ari, Loader=yaml.FullLoader) + sequenz = data['DATABASE_URI'] + \ No newline at end of file