Serves contribute.json with Flask.
This commit is contained in:
Родитель
575a200bee
Коммит
132538f734
|
@ -4,6 +4,7 @@ from flask import Flask
|
|||
from recommendation import conf
|
||||
from recommendation.cors import cors_headers
|
||||
from recommendation.views.main import main
|
||||
from recommendation.views.static import static
|
||||
from recommendation.views.status import status
|
||||
|
||||
|
||||
|
@ -11,6 +12,7 @@ def create_app():
|
|||
app = Flask(__name__)
|
||||
app.after_request(cors_headers)
|
||||
app.register_blueprint(main)
|
||||
app.register_blueprint(static)
|
||||
app.register_blueprint(status)
|
||||
app.config.update(
|
||||
CELERY_BROKER_URL=conf.CELERY_BROKER_URL,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
from os import path, pardir
|
||||
from flask import Blueprint, send_file
|
||||
|
||||
|
||||
static = Blueprint('static', __name__)
|
||||
STATIC_DIR = path.join(path.dirname(path.abspath(__file__)), pardir, 'static')
|
||||
|
||||
|
||||
@static.route('/contribute.json')
|
||||
def lbheartbeat():
|
||||
return send_file(path.join(STATIC_DIR, 'contribute.json'))
|
|
@ -0,0 +1,15 @@
|
|||
import json
|
||||
from os import path
|
||||
|
||||
from nose.tools import eq_
|
||||
|
||||
from recommendation.tests.util import AppTestCase
|
||||
from recommendation.views.static import STATIC_DIR
|
||||
|
||||
|
||||
class TestStaticViews(AppTestCase):
|
||||
def test_contribute(self):
|
||||
response = self.client.get('/contribute.json')
|
||||
eq_(response.status_code, 200)
|
||||
with open(path.join(STATIC_DIR, 'contribute.json')) as file_data:
|
||||
eq_(json.load(file_data), response.json)
|
Загрузка…
Ссылка в новой задаче