mirror of
https://github.com/Xevion/power-math.git
synced 2025-12-06 17:15:54 -06:00
add basic Flask server files
This commit is contained in:
28
server/config.py
Normal file
28
server/config.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
"""config.py
|
||||||
|
Stores all configurations for this Flask app. Would be used for storing storing and access development
|
||||||
|
and production secret keys.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
configs = {
|
||||||
|
'development': 'server.config.DevelopmentConfig',
|
||||||
|
'production': 'server.config.ProductionConfig',
|
||||||
|
'testing': 'server.config.TestingConfig'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Base configuration for the app."""
|
||||||
|
|
||||||
|
|
||||||
|
class DevelopmentConfig(Config):
|
||||||
|
"""Development configuration for the app."""
|
||||||
|
|
||||||
|
|
||||||
|
class ProductionConfig(Config):
|
||||||
|
"""Production configuration for the app."""
|
||||||
|
|
||||||
|
|
||||||
|
class TestingConfig(Config):
|
||||||
|
"""Testing configuraiton for the app."""
|
||||||
29
server/create_app.py
Normal file
29
server/create_app.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
from flask import Flask, render_template
|
||||||
|
|
||||||
|
from server.config import configs
|
||||||
|
|
||||||
|
def create_app(env = None):
|
||||||
|
app = Flask(
|
||||||
|
__name__,
|
||||||
|
static_folder="./../dist/static",
|
||||||
|
template_folder="./../dist"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not env:
|
||||||
|
env = app.config['ENV']
|
||||||
|
app.config.from_object(configs[env])
|
||||||
|
|
||||||
|
@app.shell_context_processor
|
||||||
|
def shell_context():
|
||||||
|
pass
|
||||||
|
|
||||||
|
with app.app_context():
|
||||||
|
#noinspection PyUnresolvedReferences
|
||||||
|
from server import api
|
||||||
|
|
||||||
|
@app.route('/', defaults={'path': ''})
|
||||||
|
@app.route('/<path:path>')
|
||||||
|
def catch_all(path):
|
||||||
|
return render_template("index.html")
|
||||||
|
|
||||||
|
return app
|
||||||
Reference in New Issue
Block a user