Skip to content

Commit ddcc82d

Browse files
committed
Removed @db_create method and moved to run.py
1 parent 7af027f commit ddcc82d

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

app.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@
1111
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
1212
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
1313
app.config['PROPAGATE_EXCEPTIONS'] = True
14-
app.secret_key = 'jose'
14+
app.secret_key = 'vijay'
1515
api = Api(app)
1616

17-
18-
@app.before_first_request
19-
def create_tables():
20-
db.create_all()
21-
22-
2317
jwt = JWT(app, authenticate, identity) # /auth
2418

2519
api.add_resource(Store, '/store/<string:name>')
@@ -31,4 +25,9 @@ def create_tables():
3125
if __name__ == '__main__':
3226
from db import db
3327
db.init_app(app)
28+
if app.config['DEBUG']:
29+
@app.before_first_request
30+
def create_tables():
31+
db.create_all()
32+
3433
app.run(port=5000, debug=True)

run.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from app import app
2+
from db import db
3+
4+
db.init_app(app)
5+
6+
@app.before_first_request
7+
def create_tables():
8+
db.create_all()

0 commit comments

Comments
 (0)