Adding MYSQL support
This commit is contained in:
parent
2560c34257
commit
cf5d7495f0
5 changed files with 23 additions and 6 deletions
|
@ -11,6 +11,7 @@ nose==1.3.7
|
|||
pbr==2.0.0
|
||||
pycodestyle==2.3.1
|
||||
pyflakes==1.5.0
|
||||
PyMySQL==0.7.11
|
||||
six==1.10.0
|
||||
SQLAlchemy==1.1.9
|
||||
visitor==0.1.3
|
||||
|
|
3
setup.py
3
setup.py
|
@ -27,7 +27,8 @@ setup(
|
|||
install_requires=[
|
||||
'flask',
|
||||
'flask-bootstrap',
|
||||
'flask-sqlalchemy'
|
||||
'flask-sqlalchemy',
|
||||
'pymysql'
|
||||
],
|
||||
author="Denis Nutiu",
|
||||
author_email="denis.nutiu@gmail.com",
|
||||
|
|
|
@ -19,6 +19,7 @@ from src.models import db
|
|||
from src.views.errors import error_pages
|
||||
from src.views.scoreboard import scoreboard
|
||||
from src.config import config
|
||||
import sys
|
||||
import flask_bootstrap
|
||||
import flask
|
||||
|
||||
|
@ -35,8 +36,11 @@ def create_app(config_name):
|
|||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app('default')
|
||||
try:
|
||||
app = create_app(sys.argv[1])
|
||||
except (IndexError, KeyError):
|
||||
print("Using default configuration.")
|
||||
app = create_app('default')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -40,7 +40,18 @@ class DevelopmentConfig(Config):
|
|||
|
||||
class ProductionConfig(Config):
|
||||
BOOTSTRAP_USE_MINIFIED = True
|
||||
MYSQL_USERNAME = ""
|
||||
MYSQL_PASSWORD = ""
|
||||
MYSQL_HOSTNAME = ""
|
||||
MYSQL_DATABASE = ""
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://{username}:{password}@{hostname}/{database}'\
|
||||
.format(username = MYSQL_USERNAME, password = MYSQL_PASSWORD,
|
||||
hostname = MYSQL_HOSTNAME, database = MYSQL_DATABASE)
|
||||
|
||||
@staticmethod
|
||||
def init_app(app):
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
class TestingConfig(Config):
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'test_database.sqlite')
|
||||
|
|
|
@ -39,9 +39,9 @@ def upload():
|
|||
content = flask.request.get_json()
|
||||
|
||||
try:
|
||||
gpu = flask.escape(content['gpu'])
|
||||
cpu = flask.escape(content['cpu'])
|
||||
log = flask.escape(content['log'])
|
||||
gpu = content['gpu']
|
||||
cpu = content['cpu']
|
||||
log = content['log']
|
||||
score = int(content['score'])
|
||||
except KeyError: # Json doesn't contain the keys we need.
|
||||
error = "invalid json keys: gpu, cpu, log, score"
|
||||
|
|
Loading…
Reference in a new issue