Moved
This commit is contained in:
parent
bc62ef4f0d
commit
a18333c2c3
101 changed files with 54 additions and 59 deletions
10
Dockerfile
10
Dockerfile
|
|
@ -1,6 +1,6 @@
|
||||||
FROM node:latest
|
FROM python:latest
|
||||||
WORKDIR /app-frontend
|
WORKDIR /data/backend
|
||||||
COPY ["package.json", "package-lock.json*", "./"]
|
COPY requirements.txt requirements.txt
|
||||||
RUN npm install
|
RUN pip install --upgrade pip
|
||||||
RUN npm install -g @angular/cli
|
RUN pip install -r requirements.txt
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
import sys
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
|
||||||
|
|
||||||
|
|
||||||
def create_app(flask_env='development'):
|
def create_app(flask_env='development'):
|
||||||
app = Flask(__name__, instance_relative_config=False)
|
app = Flask(__name__, instance_relative_config=False, static_url_path='')
|
||||||
origin = app.config.get('ALLOW_ORIGIN')
|
origin = app.config.get('ALLOW_ORIGIN')
|
||||||
if origin is None:
|
if origin is None:
|
||||||
origin = ['http://127.0.0.1:4200', 'http://localhost:4200']
|
origin = ['http://127.0.0.1:5000', 'http://localhost:5000']
|
||||||
CORS(app, supports_credentials=True, origins=origin)
|
CORS(app, supports_credentials=True, origins=origin)
|
||||||
if flask_env == 'production':
|
if flask_env == 'production':
|
||||||
app.config.from_object("config.ProductionConfig")
|
app.config.from_object("config.ProductionConfig")
|
||||||
|
|
@ -21,15 +17,7 @@ def create_app(flask_env='development'):
|
||||||
else:
|
else:
|
||||||
app.config.from_object("config.Config")
|
app.config.from_object("config.Config")
|
||||||
|
|
||||||
if app.config['SQLALCHEMY_DATABASE_URI_1'] is None or app.config['SQLALCHEMY_DATABASE_URI_2'] is None:
|
|
||||||
print('No ENV Variable for DATABASE_URL_USERS or DATABASE_URL_LOGS')
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
print('ENV Variables passed : ', app.config['SQLALCHEMY_BINDS'])
|
|
||||||
|
|
||||||
db.init_app(app)
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
from . import routes
|
from . import routes
|
||||||
app.register_blueprint(routes.bp)
|
app.register_blueprint(routes.bp)
|
||||||
db.create_all()
|
|
||||||
return app
|
return app
|
||||||
7
app.py
Normal file
7
app.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from . import create_app
|
||||||
|
import os
|
||||||
|
|
||||||
|
app = create_app(os.environ.get('FLASK_ENV', None))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(host='0.0.0.0', DEBUG=True)
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
FROM python:latest
|
|
||||||
WORKDIR /data/backend
|
|
||||||
COPY requirements.txt requirements.txt
|
|
||||||
RUN pip install --upgrade pip
|
|
||||||
RUN pip install -r requirements.txt
|
|
||||||
COPY . .
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
from application import create_app
|
|
||||||
import os
|
|
||||||
|
|
||||||
app = create_app(os.environ.get('FLASK_ENV', None))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
PORT = os.environ.get('PORT', 33507)
|
|
||||||
app.run(host='0.0.0.0', port=PORT, DEBUG=True)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
alembic==1.7.5
|
|
||||||
Flask==2.0.2
|
|
||||||
Flask-Migrate==3.1.0
|
|
||||||
Flask-Script==2.0.6
|
|
||||||
Flask-Testing==0.8.1
|
|
||||||
Flask-SQLAlchemy==2.5.1
|
|
||||||
Flask-WTF==0.15.1
|
|
||||||
pipreqs==0.4.10
|
|
||||||
PyJWT==2.3.0
|
|
||||||
pytest==6.2.5
|
|
||||||
SQLAlchemy==1.4.27
|
|
||||||
psycopg2==2.9.2
|
|
||||||
Flask-Cors==3.0.10
|
|
||||||
|
|
@ -10,6 +10,7 @@ class Config(object):
|
||||||
|
|
||||||
FLASK_APP = os.environ.get('FLASK_APP', None)
|
FLASK_APP = os.environ.get('FLASK_APP', None)
|
||||||
FLASK_ENV = os.environ.get('FLASK_ENV', None)
|
FLASK_ENV = os.environ.get('FLASK_ENV', None)
|
||||||
|
FLASK_RUN_PORT = os.environ.get('FLASK_RUN_PORT', 4200)
|
||||||
|
|
||||||
API_URL = os.environ.get('API_URL', 'http://127.0.0.1:5000/api/')
|
API_URL = os.environ.get('API_URL', 'http://127.0.0.1:5000/api/')
|
||||||
|
|
||||||
|
|
@ -15,3 +15,5 @@ last 2 Safari major versions
|
||||||
last 2 iOS major versions
|
last 2 iOS major versions
|
||||||
Firefox ESR
|
Firefox ESR
|
||||||
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
||||||
|
not ios_saf 15.2-15.3
|
||||||
|
not safari 15.2-15.3
|
||||||
0
.gitignore → frontend/.gitignore
vendored
0
.gitignore → frontend/.gitignore
vendored
6
frontend/Dockerfile
Normal file
6
frontend/Dockerfile
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
FROM node:latest
|
||||||
|
WORKDIR /app-frontend
|
||||||
|
COPY ["package.json", "package-lock.json*", "./"]
|
||||||
|
RUN npm install
|
||||||
|
RUN npm install -g @angular/cli
|
||||||
|
COPY . .
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:browser",
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "backend/static",
|
"outputPath": "dist/",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"polyfills": "src/polyfills.ts",
|
"polyfills": "src/polyfills.ts",
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng build --prod --build-optimizer --baseHref=”/static/” && node server.js",
|
"start": "ng build && python flask run",
|
||||||
"build": "ng build --prod --build-optimizer --baseHref=”/static/”",
|
"build": "ng build --build-optimizer --baseHref=frontend/dist",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test"
|
"test": "ng test"
|
||||||
},
|
},
|
||||||
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 197 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
|
@ -1,4 +1,4 @@
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
debutUrl: 'http://127.0.0.1:5000/api/'
|
debutUrl: 'http://127.0.0.1:4200/api/'
|
||||||
};
|
};
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
debutUrl: 'http://127.0.0.1:5000/api/'
|
debutUrl: 'http://127.0.0.1:4200/api/'
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Before Width: | Height: | Size: 948 B After Width: | Height: | Size: 948 B |
7
requirements.txt
Normal file
7
requirements.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
Flask==2.0.2
|
||||||
|
Flask-Testing==0.8.1
|
||||||
|
Flask-WTF==0.15.1
|
||||||
|
PyJWT==2.3.0
|
||||||
|
pytest==6.2.5
|
||||||
|
psycopg2==2.9.2
|
||||||
|
Flask-Cors==3.0.10
|
||||||
|
|
@ -1,28 +1,29 @@
|
||||||
from flask import request, Blueprint, render_template, current_app as app
|
from flask import request, Blueprint, send_from_directory, current_app as app
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
from werkzeug.exceptions import HTTPException
|
from werkzeug.exceptions import HTTPException
|
||||||
from .responses import send_message, send_error
|
from .responses import send_message, send_error
|
||||||
import requests
|
|
||||||
from .sessionJWT import create_auth_token, check_auth_token
|
from .sessionJWT import create_auth_token, check_auth_token
|
||||||
|
|
||||||
|
|
||||||
# Request Post
|
# Request Post
|
||||||
def request_post(url, data_json):
|
def request_post(url, data_json):
|
||||||
return requests.post(app.config['SQLALCHEMY_BINDS'] + url, json=data_json)
|
return requests.post(app.config['API_URL'] + url, json=data_json)
|
||||||
|
|
||||||
|
|
||||||
# Request Put
|
# Request Put
|
||||||
def request_put(url, data_json):
|
def request_put(url, data_json):
|
||||||
return requests.put(app.config['SQLALCHEMY_BINDS'] + url, json=data_json)
|
return requests.put(app.config['API_URL'] + url, json=data_json)
|
||||||
|
|
||||||
|
|
||||||
# Request Get
|
# Request Get
|
||||||
def request_get(url):
|
def request_get(url):
|
||||||
return requests.get(app.config['SQLALCHEMY_BINDS'] + url)
|
return requests.get(app.config['API_URL'] + url)
|
||||||
|
|
||||||
|
|
||||||
# Request Delete
|
# Request Delete
|
||||||
def request_delete(url, data_json):
|
def request_delete(url, data_json):
|
||||||
return requests.delete(app.config['SQLALCHEMY_BINDS'] + url, json=data_json)
|
return requests.delete(app.config['API_URL'] + url, json=data_json)
|
||||||
|
|
||||||
|
|
||||||
bp = Blueprint('myapp', __name__)
|
bp = Blueprint('myapp', __name__)
|
||||||
|
|
@ -35,7 +36,17 @@ def handle_exception(e):
|
||||||
|
|
||||||
@bp.route('/', methods=['GET'])
|
@bp.route('/', methods=['GET'])
|
||||||
def root():
|
def root():
|
||||||
return render_template('index.html')
|
return send_from_directory("frontend/dist", "index.html")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/frontend/dist/<path:path>', methods=['GET'])
|
||||||
|
def static(path):
|
||||||
|
return send_from_directory("frontend/dist", path)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/assets/<path:path>', methods=['GET'])
|
||||||
|
def assets(path):
|
||||||
|
return send_from_directory("frontend/dist/assets", path)
|
||||||
|
|
||||||
|
|
||||||
# Login
|
# Login
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue