worked on db etc

master
Kostanjevec 2022-04-25 00:32:17 +02:00
parent ced983d5ed
commit 9229489221
9 changed files with 84 additions and 1 deletions

12
.gitignore vendored
View File

@ -138,3 +138,15 @@ dmypy.json
# Cython debug symbols # Cython debug symbols
cython_debug/ cython_debug/
*.pyc
__pycache__/
instance/
.pytest_cache/
.coverage
htmlcov/
dist/
build/
*.egg-info/

32
app/__init__.py 100644
View File

@ -0,0 +1,32 @@
import os
from flask import Flask
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY='dev',
DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),
)
if test_config is None:
# load the instance config, if it exists, when not testing
app.config.from_pyfile('config.py', silent=True)
else:
# load the test config if passed in
app.config.from_mapping(test_config)
# ensure the instance folder exists
try:
os.makedirs(app.instance_path)
except OSError:
pass
# a simple page that says hello
@app.route('/hello')
def hello():
return 'Hello, Woooorld!'
return app

View File

@ -1,5 +1,17 @@
#!/usr/bin/python3 #!/usr/bin/python3
""""
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
"""
"""
from flask import Flask, render_template, Blueprint from flask import Flask, render_template, Blueprint
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
@ -15,7 +27,6 @@ from create_db import #baze?
# Flask app # Flask app
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = CONFIG['DB_CONNECTION'] app.config['SQLALCHEMY_DATABASE_URI'] = CONFIG['DB_CONNECTION']
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
@ -62,3 +73,5 @@ def index():
if __name__ == "__main__": if __name__ == "__main__":
app.run(debug=True, host = "0.0.0.0") app.run(debug=True, host = "0.0.0.0")
"""

0
app/auth.py 100644
View File

View File

View File

View File

View File

View File

@ -1,5 +1,10 @@
#!/usr/bin/python3 #!/usr/bin/python3
from csv import unregister_dialect
import email
from sqlite3 import Date
from ssl import _PasswordType
from xmlrpc.client import DateTime
from sqlalchemy import Column, Integer, Float, String, Text, TIMESTAMP,ForeignKey from sqlalchemy import Column, Integer, Float, String, Text, TIMESTAMP,ForeignKey
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
@ -10,12 +15,33 @@ Base = declarative_base()
class USER(Base): class USER(Base):
__tablename__ = 'user'
id = Column(Integer, primary_key=True, autoincrement=True)
username = Column(String)
password = Column(String) #mogoče raje kaj drugega, neki hash passworda al neki
email = Column(String)
class Item(Base): class Item(Base):
__tablename__ = 'item'
id = Column(Integer, primary_key=True, autoincrement=True)
owner_id = Column(String, ForeignKey("user.id"), nullable=False)
item_location = Column(String)
item_type = Column(String)
item_size = Column(Integer)
class Interest(Base): class Interest(Base):
__tablename__ = 'interest'
pdf_id = Column(String, ForeignKey("item.id"), nullable=False)
user_id = Column(String, ForeignKey("user.id"), nullable=False)
interest_rate = Column(Float)
#ali
# date_added = Column(String)
# last_review = Column(DateTime)
# interval = Column(Integer)
# due = Column(DateTime)
engine = create_engine(CONFIG['DB_CONNECTION']) engine = create_engine(CONFIG['DB_CONNECTION'])