initial commit
This commit is contained in:
commit
949086d605
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.idea
|
||||
venv
|
||||
*.pyc
|
||||
data/db.sqlite
|
||||
__pycache__
|
10
config.py
Normal file
10
config.py
Normal file
@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
basepath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
DATA_DIR = os.path.join(basepath, "data")
|
||||
DATABASE_FILE = os.path.join(DATA_DIR, "db.sqlite")
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(DATABASE_FILE)
|
||||
MAKEDIRS = [
|
||||
DATA_DIR,
|
||||
]
|
7
oshipka.py
Normal file
7
oshipka.py
Normal file
@ -0,0 +1,7 @@
|
||||
from persistance.populate import init_db
|
||||
from webapp import app
|
||||
|
||||
if __name__ == "__main__":
|
||||
init_db(app)
|
||||
|
||||
app.run(debug=True)
|
0
persistance/__init__.py
Normal file
0
persistance/__init__.py
Normal file
8
persistance/models.py
Normal file
8
persistance/models.py
Normal file
@ -0,0 +1,8 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
from flask import render_template, request
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from sqlalchemy_utils import ChoiceType
|
||||
|
||||
db = SQLAlchemy()
|
22
persistance/populate.py
Normal file
22
persistance/populate.py
Normal file
@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE
|
||||
from persistance.models import db
|
||||
|
||||
|
||||
def populate_db(app):
|
||||
with app.app_context():
|
||||
pass
|
||||
|
||||
|
||||
def init_db(app):
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
|
||||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
||||
|
||||
db.init_app(app)
|
||||
for dir in MAKEDIRS:
|
||||
os.makedirs(dir, exist_ok=True)
|
||||
if not os.path.exists(DATABASE_FILE):
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
populate_db(app)
|
8
requirements.txt
Normal file
8
requirements.txt
Normal file
@ -0,0 +1,8 @@
|
||||
click==7.1.1
|
||||
Flask==1.1.1
|
||||
Flask-SQLAlchemy==2.4.1
|
||||
itsdangerous==1.1.0
|
||||
Jinja2==2.11.1
|
||||
MarkupSafe==1.1.1
|
||||
SQLAlchemy==1.3.15
|
||||
Werkzeug==1.0.0
|
4
webapp/__init__.py
Normal file
4
webapp/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config["SECRET_KEY"] = "UNSECRET_KEY....478932fjkdsl"
|
Loading…
Reference in New Issue
Block a user