Update env file

This commit is contained in:
Andros 2018-02-11 18:02:41 +01:00
parent 0731585373
commit 2a70ca9dae
3 changed files with 24 additions and 8 deletions

6
app.py
View File

@ -3,8 +3,9 @@
# ========================= # =========================
# Librarys # Librarys
# ========================= # =========================
from dotenv import load_dotenv, find_dotenv
import os import os
from os.path import join, dirname
from dotenv import load_dotenv
from flask import Flask, request from flask import Flask, request
from flask_restplus import Resource, Api from flask_restplus import Resource, Api
from models import db, User, Notice, Comment from models import db, User, Notice, Comment
@ -13,7 +14,8 @@ from flask_marshmallow import Marshmallow
# ========================= # =========================
# Extensions initialization # Extensions initialization
# ========================= # =========================
load_dotenv(find_dotenv()) dotenv_path = join(dirname(__file__), 'env')
load_dotenv(dotenv_path)
app = Flask(__name__) app = Flask(__name__)
ma = Marshmallow(app) ma = Marshmallow(app)
api = Api(app) api = Api(app)

3
env Normal file
View File

@ -0,0 +1,3 @@
DEBUG=True
DATABASE_URI='sqlite:///database.sqlite'
SECRET_KEY='my secret'

View File

@ -1,14 +1,17 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Librarys # Librarys
import os import os
from os.path import join, dirname
from flask import Flask from flask import Flask
from datetime import datetime from datetime import datetime
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand from flask_migrate import Migrate, MigrateCommand
from dotenv import load_dotenv, find_dotenv from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), 'env')
load_dotenv(dotenv_path)
load_dotenv(find_dotenv())
app = Flask(__name__) app = Flask(__name__)
@ -58,7 +61,11 @@ class Notice(db.Model):
# Relations # Relations
user = db.relationship( user = db.relationship(
'User', backref=db.backref('Notice', lazy=True, cascade="all, delete-orphan")) 'User',
backref=db.backref(
'Notice',
lazy=True,
cascade="all, delete-orphan"))
def __repr__(self): def __repr__(self):
return '<Notice Table {0}>'.format(self.title) return '<Notice Table {0}>'.format(self.title)
@ -82,9 +89,13 @@ class Comment(db.Model):
# Relations # Relations
user = db.relationship( user = db.relationship(
'User', backref=db.backref('Comment', lazy=True, cascade="all, delete-orphan")) 'User',
notice = db.relationship( backref=db.backref(
'Notice', backref=db.backref('Comment', lazy=True, cascade="all, delete-orphan")) 'Comment',
lazy=True,
cascade="all, delete-orphan"))
notice = db.relationship('Notice', backref=db.backref(
'Comment', lazy=True, cascade="all, delete-orphan"))
def __repr__(self): def __repr__(self):
return '<Comment Table {0}>'.format(self.id) return '<Comment Table {0}>'.format(self.id)