Skip to content

Commit

Permalink
first-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bermeki1996 committed Mar 20, 2022
0 parents commit 3cb605f
Show file tree
Hide file tree
Showing 18 changed files with 321 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cfg.yaml
.env
venv
__pycashe__
database.db
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn run:app
Binary file added __pycache__/app.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/config.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/data_cfg.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/yaml_data_cfg.cpython-39.pyc
Binary file not shown.
112 changes: 112 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -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 '<h1> The user is not exested<h1>'

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)

27 changes: 27 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from app import app



if __name__=="__main__":
app.run(debug=True)
Binary file added static/.DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block title %}{% endblock %}
</head>
<body>


{% block body %}{% endblock %}

</body>
</html>
21 changes: 21 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{{ wtf.quick_form(form) }}

<!--{{ url_for('static', filename='css/')}}-->

{% block head %}

<link href="{{ url_for('static', filename='css/index.css')}}" rel="stylesheet">
{% endblock %}



{% block body %}
<div class="system">
<h1> Hallo von Homepage</h1>
<a href="{{url_for('user')}}">Logn in</a>
<a href="{{url_for('regist')}}"> Sign Up</a>
</div>

{% endblock %}
31 changes: 31 additions & 0 deletions templates/log.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{{ wtf.quick_form(form) }}



{% block head %}

<link href="{{ url_for('static', filename='css/log.css')}}" rel="stylesheet">
{% endblock %}



{% block body %}

<form action="/log" method="post">

{{ form.hidden_tag() }}
{{wtf.form_field(form.email)}}
{{wtf.form_field(form.password)}}

<input type="submit" name="submit">


</form>





{% endblock %}
16 changes: 16 additions & 0 deletions templates/office.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{{ wtf.quick_form(form) }}



{% block head %}

<link href="{{ url_for('static', filename='css/off.css')}}" rel="stylesheet">
{% endblock %}



{% block body %}
<h1> Hallo von Office</h1>
{% endblock %}
59 changes: 59 additions & 0 deletions templates/regester.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{{ wtf.quick_form(form) }}

{% block head %}

<link href="{{ url_for('static', filename='css/regeseter.css')}}" rel="stylesheet">
{% endblock %}



{% block body %}
{% block content %}
<div class="form-wrapper">

<div class="logo">
<img
src="{{ url_for('static', filename='dist/img/logo.png') }}"
alt="logo"
/>
</div>

{% for message in get_flashed_messages() %}
<div class="alert alert-warning">
<button
type="button"
class="close"
data-dismiss="alert">
x
</button>
{{ message }}
</div>
{% endfor %}

<h1>Sign Up</h1>

{% endblock %}
<form action="/regester" method="post">




{{ form.hidden_tag() }}
{{wtf.form_field(form.vorname)}}
{{wtf.form_field(form.nachname)}}
{{wtf.form_field(form.email)}}
{{wtf.form_field(form.password)}}
<input type="submit" name="submit">




</form>





{% endblock %}
5 changes: 5 additions & 0 deletions yaml_data_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import yaml
with open('cfg.yaml') as ari:
data = yaml.load(ari, Loader=yaml.FullLoader)
sequenz = data['DATABASE_URI']

0 comments on commit 3cb605f

Please sign in to comment.