update init to create folder structure

This commit is contained in:
lza_menace 2020-08-09 22:47:14 -07:00
parent 0c0d9c816b
commit d2f93359b0
1 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,9 @@
import json import json
from os import makedirs
from flask import Flask, request, session from flask import Flask, request, session
from flask import render_template, flash from flask import render_template, flash
from flask_session import Session from flask_session import Session
from suchwow import config
from suchwow.models import Post, Profile, Comment, Notification, db from suchwow.models import Post, Profile, Comment, Notification, db
from suchwow.routes import auth, comment, post, profile from suchwow.routes import auth, comment, post, profile
from suchwow.utils.decorators import login_required from suchwow.utils.decorators import login_required
@ -37,8 +39,13 @@ def about():
def not_found(error): def not_found(error):
return "nothin there, brah" return "nothin there, brah"
@app.cli.command("dbinit") @app.cli.command("init")
def dbinit(): def init():
# create subdirs
for i in ["uploads", "db", "wallet"]:
makedirs(f"{config.DATA_FOLDER}/{i}", exist_ok=True)
# init db
db.create_tables([Post, Profile, Comment, Notification]) db.create_tables([Post, Profile, Comment, Notification])
if __name__ == "__main__": if __name__ == "__main__":