-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
42 lines (31 loc) · 989 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
from flask.ext.script import Manager
from getpass import getpass
from werkzeug.security import generate_password_hash
#from tuneful.models import Song, File
from tuneful import app
#from flask.ext.migrate import Migrate, MigrateCommand
from tuneful.database import Base
manager = Manager(app)
class DB(object):
def __init__(self, metadata):
self.metadata = metadata
#migrate = Migrate(app, DB(Base.metadata))
#manager.add_command('db', MigrateCommand)
@manager.command
def run():
port = int(os.environ.get('PORT', 8080))
app.run(host='0.0.0.0', port=port)
from tuneful.models import Song, File
from tuneful.database import session
@manager.command
def seed():
fileR = File(filename="red_song.mp3")
fileB = File(filename="blue_song.mp3")
session.add_all([fileR, fileB])
songR = Song(file=fileR)
songB = Song(file=fileB)
session.add_all([songR, songB])
session.commit()
if __name__ == "__main__":
manager.run()