Update: save Docker nginx Angular Node Flask
This commit is contained in:
parent
1a3bee1846
commit
fcedd7534c
16 changed files with 89 additions and 84 deletions
|
|
@ -1,7 +1,5 @@
|
|||
FROM python:latest
|
||||
WORKDIR /data/frontend/backend
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
COPY . .
|
||||
WORKDIR /data/frontend
|
||||
|
|
|
|||
9
frontend/backend/app.py
Normal file
9
frontend/backend/app.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
print("Import backend")
|
||||
from application import create_app
|
||||
print("Import os")
|
||||
import os
|
||||
|
||||
app = create_app(os.environ.get('FLASK_ENV'))
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host='0.0.0.0', DEBUG=True)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
print("Import Flask")
|
||||
from flask import Flask
|
||||
print("Import Flask-Cors")
|
||||
from flask_cors import CORS
|
||||
|
||||
|
||||
def create_app(flask_env='development'):
|
||||
print("create app")
|
||||
app = Flask(__name__, instance_relative_config=False, static_url_path='')
|
||||
origin = app.config.get('ALLOW_ORIGIN')
|
||||
if origin is None:
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
print("Import responses Flask")
|
||||
from flask import current_app as app
|
||||
print("Import Json")
|
||||
import json
|
||||
|
||||
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
print("Import Flask")
|
||||
from flask import request, Blueprint, send_from_directory, current_app as app
|
||||
print("Import Requests")
|
||||
import requests
|
||||
print("Import werkzeug")
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from .responses import send_message, send_error
|
||||
from .sessionJWT import create_auth_token, check_auth_token
|
||||
|
|
@ -33,21 +36,6 @@ def handle_exception(e):
|
|||
return send_error(e.code, e.name)
|
||||
|
||||
|
||||
@bp.route('/', methods=['GET'])
|
||||
def root():
|
||||
return send_from_directory("dist", "index.html")
|
||||
|
||||
|
||||
@bp.route('/frontend/backend/dist/<path:path>', methods=['GET'])
|
||||
def static(path):
|
||||
return send_from_directory("dist", path)
|
||||
|
||||
|
||||
@bp.route('/assets/<path:path>', methods=['GET'])
|
||||
def assets(path):
|
||||
return send_from_directory("dist/assets", path)
|
||||
|
||||
|
||||
# Login
|
||||
@bp.route('/api/login', methods=['POST'])
|
||||
def login():
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
print("Import datetime")
|
||||
from datetime import datetime, timedelta
|
||||
print("Import sessionJWT Flask")
|
||||
from flask import current_app as app
|
||||
print("Import jwt")
|
||||
import jwt
|
||||
|
||||
|
||||
33
frontend/backend/config.py
Normal file
33
frontend/backend/config.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
print("Import os")
|
||||
import os
|
||||
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
class Config(object):
|
||||
DEBUG = False
|
||||
TESTING = False
|
||||
CSRF_ENABLED = True
|
||||
|
||||
FLASK_APP = os.environ.get('FLASK_APP', None)
|
||||
FLASK_ENV = os.environ.get('FLASK_ENV', None)
|
||||
FLASK_RUN_PORT = os.environ.get('FLASK_RUN_PORT', 5000)
|
||||
|
||||
API_URL = os.environ.get('API_URL', 'http://127.0.0.1:5001/api/')
|
||||
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'default_secret_key')
|
||||
ALLOW_ORIGIN = os.environ.get('ALLOW_ORIGIN', None)
|
||||
|
||||
|
||||
class ProductionConfig(Config):
|
||||
DEBUG = False
|
||||
API_URL = os.environ.get('API_URL', 'http://10.1.2.10:5000/api/')
|
||||
|
||||
|
||||
class TestingConfig(Config):
|
||||
TESTING = True
|
||||
|
||||
|
||||
class DevelopmentConfig(Config):
|
||||
DEVELOPMENT = True
|
||||
DEBUG = True
|
||||
Loading…
Add table
Add a link
Reference in a new issue