-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
48 lines (36 loc) · 1.05 KB
/
run.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
43
44
45
46
47
48
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'localhost'
db = SQLAlchemy(app)
class Song(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(255))
artist = db.Column(db.String(255))
genre = db.Column(db.String(255))
uploadTime = db.Column(db.DateTime)
playTime = db.Column(db.DateTime)
playCount = db.Column(db.Integer)
def __init__ (self, title, artist, genre, uploadTime = None, playTime = None, playCount = -1):
self.title = title
self.artist = artist
self.genre = genre
if uploadTime is None:
uploadTime = datetime.utcnow()
self.uploadTime = uploadTime
if playTime is None:
playTime = datetime.utcnow()
self.playTime = playTime
if playCount is -1:
playTime = 0
self.playTime = playTime
def __repr__(self):
return '<Song %r>' % self.title
from app import app
app.run(debug=True)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()