worked on db etc
parent
ced983d5ed
commit
9229489221
|
@ -138,3 +138,15 @@ dmypy.json
|
|||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
*.pyc
|
||||
__pycache__/
|
||||
|
||||
instance/
|
||||
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
|
||||
dist/
|
||||
build/
|
||||
*.egg-info/
|
|
@ -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
|
|
@ -1,5 +1,17 @@
|
|||
#!/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 sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
@ -15,7 +27,6 @@ from create_db import #baze?
|
|||
|
||||
# Flask app
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = CONFIG['DB_CONNECTION']
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
|
||||
|
||||
|
@ -62,3 +73,5 @@ def index():
|
|||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host = "0.0.0.0")
|
||||
|
||||
"""
|
26
create_db.py
26
create_db.py
|
@ -1,5 +1,10 @@
|
|||
#!/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.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import relationship
|
||||
|
@ -10,12 +15,33 @@ Base = declarative_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):
|
||||
__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):
|
||||
__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'])
|
||||
|
|
Loading…
Reference in New Issue