mirror of
https://github.com/Xevion/power-math.git
synced 2025-12-06 11:15:52 -06:00
change to Flask-RESTful, implement basic Question/Category/Categories classes, functionality outlined
This commit is contained in:
@@ -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': ''})
|
||||
|
||||
Reference in New Issue
Block a user