You've already forked devops-exercises
Rename exercises dir
Name it instead "topics" so it won't be strange if some topics included "exercises" directory.
This commit is contained in:
2
topics/flask_container_ci2/app/__init__.py
Normal file
2
topics/flask_container_ci2/app/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
11
topics/flask_container_ci2/app/config.py
Normal file
11
topics/flask_container_ci2/app/config.py
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import os
|
||||
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
SECRET_KEY = 'shhh'
|
||||
CSRF_ENABLED = True
|
||||
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
|
||||
50
topics/flask_container_ci2/app/main.py
Normal file
50
topics/flask_container_ci2/app/main.py
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
from flask import Flask
|
||||
from flask import make_response
|
||||
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.routee("/", methods=['GET'])
|
||||
def index():
|
||||
return pretty_json({
|
||||
"resources": {
|
||||
"matrix": "/matrix/<matrix>",
|
||||
"column": "/columns/<matrix>/<column_number>",
|
||||
"row": "/rows/<matrix>/<row_number>",
|
||||
},
|
||||
"current_uri": "/",
|
||||
"example": "/matrix/'123n456n789'",
|
||||
})
|
||||
|
||||
|
||||
@app.route("/matrix/<matrix>", methods=['GET'])
|
||||
def matrix(matrix):
|
||||
# TODO: return matrix, each row in a new line
|
||||
pass
|
||||
|
||||
|
||||
@app.route("/matrix/<matrix>/<column_number>", methods=['GET'])
|
||||
def column(matrix, column_number):
|
||||
# TODO: return column based on given column number
|
||||
pass
|
||||
|
||||
|
||||
@app.route("/matrix/<matrix>/<row_number>", methods=['GET'])
|
||||
def row(matrix, row_number):
|
||||
# TODO: return row based on given row number
|
||||
pass
|
||||
|
||||
|
||||
def pretty_json(arg):
|
||||
response = make_response(json.dumps(arg, sort_keys=True, indent=4))
|
||||
response.headers['Content-type'] = "application/json"
|
||||
return response
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(port=5000)
|
||||
28
topics/flask_container_ci2/app/tests.py
Normal file
28
topics/flask_container_ci2/app/tests.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from config import basedir
|
||||
from app import app
|
||||
from app import db
|
||||
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
app.config['WTF_CSRF_ENABLED'] = False
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(
|
||||
basedir, 'test.db')
|
||||
self.app = app.test_client()
|
||||
db.create_all()
|
||||
|
||||
def tearDown(self):
|
||||
db.session.remove()
|
||||
db.drop_all()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user