Add first controller
This commit is contained in:
parent
3338ba51d8
commit
39039fd533
4 changed files with 21 additions and 8 deletions
3
app/__init__.py
Normal file
3
app/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
12
app/controllers/api.py
Normal file
12
app/controllers/api.py
Normal 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"
|
|
@ -4,11 +4,8 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
from flask import Flask
|
|
||||||
from werkzeug.contrib.fixers import ProxyFix
|
from werkzeug.contrib.fixers import ProxyFix
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
# add current and parent path to syspath
|
# add current and parent path to syspath
|
||||||
currentPath = os.path.dirname(__file__)
|
currentPath = os.path.dirname(__file__)
|
||||||
parentPath = os.path.abspath(os.path.join(currentPath, os.path.pardir))
|
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:
|
if path not in sys.path:
|
||||||
sys.path.insert(0, path)
|
sys.path.insert(0, path)
|
||||||
|
|
||||||
# configure logging
|
# more imports
|
||||||
|
|
||||||
import config
|
import config
|
||||||
|
from app.services import database
|
||||||
|
from app.controllers import api
|
||||||
|
from app import app
|
||||||
|
|
||||||
|
# configure logging
|
||||||
def configure_logging(level):
|
def configure_logging(level):
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
root_logger.setLevel(level)
|
root_logger.setLevel(level)
|
||||||
|
@ -40,7 +39,6 @@ configure_logging(logging_level)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# initialize database
|
# initialize database
|
||||||
from app.services import database
|
|
||||||
database.setup()
|
database.setup()
|
||||||
|
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app)
|
app.wsgi_app = ProxyFix(app.wsgi_app)
|
2
run.sh
2
run.sh
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
python app/server.py "$@"
|
python app/run.py "$@"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue