change to Flask-RESTful, implement basic Question/Category/Categories classes, functionality outlined

This commit is contained in:
Xevion
2020-08-27 02:34:26 -05:00
parent d83cbf512b
commit ac72f2e7f6
2 changed files with 93 additions and 21 deletions

View File

@@ -1,24 +1,33 @@
from flask import Flask, render_template
from flask_restful import Api
from server.config import configs
def create_app(env = None):
def create_app(env=None):
app = Flask(
__name__,
static_folder="./../dist/static",
template_folder="./../dist"
)
# Instantiate Flask-Restful API and register appropriate routes
from server.api import Question, Category, Categories
api = Api(app, prefix='/api/')
api.add_resource(Question, '/question/', '/question/<string:question_id>')
api.add_resource(Category, '/category/<string:category_id>')
api.add_resource(Categories, '/categories/')
if not env:
env = app.config['ENV']
app.config.from_object(configs[env])
@app.shell_context_processor
def shell_context():
pass
# @app.shell_context_processor
# def shell_context():
# pass
with app.app_context():
#noinspection PyUnresolvedReferences
# noinspection PyUnresolvedReferences
from server import api
@app.route('/', defaults={'path': ''})