Add first controller

This commit is contained in:
Yax 2015-05-02 13:43:38 +02:00
parent 3338ba51d8
commit 39039fd533
4 changed files with 21 additions and 8 deletions

3
app/__init__.py Normal file
View file

@ -0,0 +1,3 @@
from flask import Flask
app = Flask(__name__)

12
app/controllers/api.py Normal file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
from app import app
logger = logging.getLogger(__name__)
@app.route("/comments", methods=['GET'])
def get_comments():
return "OK"

View file

@ -4,11 +4,8 @@
import os
import sys
import logging
from flask import Flask
from werkzeug.contrib.fixers import ProxyFix
app = Flask(__name__)
# add current and parent path to syspath
currentPath = os.path.dirname(__file__)
parentPath = os.path.abspath(os.path.join(currentPath, os.path.pardir))
@ -17,11 +14,13 @@ for path in paths:
if path not in sys.path:
sys.path.insert(0, path)
# configure logging
# more imports
import config
from app.services import database
from app.controllers import api
from app import app
# configure logging
def configure_logging(level):
root_logger = logging.getLogger()
root_logger.setLevel(level)
@ -40,7 +39,6 @@ configure_logging(logging_level)
logger = logging.getLogger(__name__)
# initialize database
from app.services import database
database.setup()
app.wsgi_app = ProxyFix(app.wsgi_app)

2
run.sh
View file

@ -1,3 +1,3 @@
#!/bin/sh
python app/server.py "$@"
python app/run.py "$@"