website online working
This commit is contained in:
@@ -39,12 +39,8 @@ app.jinja_env.autoescape = True
|
||||
|
||||
|
||||
# configuration
|
||||
UPLOADED_FILES_DEST_ITEM = ApplicationConfig.UPLOADED_FILES_DEST_ITEM
|
||||
UPLOADED_FILES_ALLOW = ApplicationConfig.UPLOADED_FILES_ALLOW
|
||||
CURRENT_SETTINGS = ApplicationConfig.CURRENT_SETTINGS
|
||||
WHITE = ApplicationConfig.WHITE
|
||||
|
||||
app.config['CORS_ORIGIN_WHITELIST'] = ApplicationConfig.CORS_ORIGIN_WHITELIST
|
||||
app.config['CORS_ALLOWED_ORIGINS'] = ApplicationConfig.CORS_ALLOWED_ORIGINS
|
||||
app.config['UPLOADED_FILES_DEST_ITEM'] = ApplicationConfig.UPLOADED_FILES_DEST_ITEM
|
||||
app.config['UPLOADED_FILES_ALLOW'] = ApplicationConfig.UPLOADED_FILES_ALLOW
|
||||
app.config['MAX_CONTENT_LENGTH'] = ApplicationConfig.MAX_CONTENT_LENGTH
|
||||
@@ -54,7 +50,6 @@ app.config['SESSION_COOKIE_HTTPONLY'] = ApplicationConfig.SESSION_COOKIE_HTTPONL
|
||||
app.config['SESSION_COOKIE_SAMESITE'] = ApplicationConfig.SESSION_COOKIE_SAMESITE
|
||||
app.config['SESSION_PERMANENT'] = ApplicationConfig.SESSION_PERMANENT
|
||||
app.config['SESSION_USE_SIGNER'] = ApplicationConfig.SESSION_USE_SIGNER
|
||||
app.config['ORIGIN_URL'] = ApplicationConfig.ORIGIN_URL
|
||||
app.config['CURRENT_SETTINGS'] = ApplicationConfig.CURRENT_SETTINGS
|
||||
app.config['SECRET_KEY'] = ApplicationConfig.SECRET_KEY
|
||||
|
||||
@@ -99,15 +94,18 @@ def load_user_from_request(request):
|
||||
return None
|
||||
|
||||
|
||||
api_main = {
|
||||
"origins": [ApplicationConfig.ORIGIN_URL],
|
||||
"methods": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"],
|
||||
"allow_headers": ['Authorization', 'application/json', 'authorization', 'Content-Type',
|
||||
'Access-Control-Allow-Headers', 'Origin,Accept',
|
||||
'X-Requested-With', 'Content-Type', 'Access-Control-Request-Method',
|
||||
'Access-Control-Request-Headers']
|
||||
}
|
||||
cors = CORS(app, supports_credentials=True, resources={r'/*': api_main})
|
||||
# api_main = {
|
||||
# "origins": [ApplicationConfig.ORIGIN_URL],
|
||||
# "methods": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"],
|
||||
# "allow_headers": ['Authorization', 'application/json', 'authorization', 'Content-Type',
|
||||
# 'Access-Control-Allow-Headers', 'Origin,Accept',
|
||||
# 'X-Requested-With', 'Content-Type', 'Access-Control-Request-cMethod',
|
||||
# 'Access-Control-Request-Headers']
|
||||
# }
|
||||
cors = CORS(app,
|
||||
supports_credentials=True,
|
||||
resources={r"/*": {"origins": ApplicationConfig.CORS_ALLOWED_ORIGINS}
|
||||
})
|
||||
|
||||
|
||||
# bind a function after each request, even if an exception is encountered.
|
||||
@@ -171,7 +169,6 @@ app.register_blueprint(main_blueprint, url_prefix='/main')
|
||||
from .customer import customer as customer_blueprint
|
||||
app.register_blueprint(customer_blueprint, url_prefix='/customer')
|
||||
|
||||
|
||||
from .delivery import delivery as delivery_blueprint
|
||||
app.register_blueprint(delivery_blueprint, url_prefix='/delivery')
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from flask import jsonify, Response, request, url_for
|
||||
from app import app, WHITE
|
||||
from flask import jsonify, Response, url_for
|
||||
from app import app
|
||||
|
||||
@app.route("/favicon.ico")
|
||||
def favicon():
|
||||
@@ -21,15 +21,3 @@ def static_from_root():
|
||||
def index():
|
||||
return jsonify({"success": "Api is online"}), 200
|
||||
|
||||
# @app.after_request
|
||||
# def add_cors_headers(response):
|
||||
# r = request.referrer[:-1]
|
||||
# if r in WHITE:
|
||||
# response.headers.add('Access-Control-Allow-Origin', r)
|
||||
# response.headers.add('Access-Control-Allow-Credentials', 'true')
|
||||
# response.headers.add('Access-Control-Allow-Headers', 'Content-Type')
|
||||
# response.headers.add('Access-Control-Allow-Headers', 'Cache-Control')
|
||||
# response.headers.add('Access-Control-Allow-Headers', 'X-Requested-With')
|
||||
# response.headers.add('Access-Control-Allow-Headers', 'Authorization')
|
||||
# response.headers.add('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE')
|
||||
# return response
|
||||
@@ -1,15 +1,10 @@
|
||||
from flask import request, jsonify
|
||||
from flask_login import current_user
|
||||
from flask import jsonify
|
||||
from sqlalchemy.sql import func
|
||||
from datetime import date, timedelta
|
||||
from app.reports import reports
|
||||
from app import db
|
||||
from datetime import datetime
|
||||
|
||||
from app.classes.auth import Auth_User
|
||||
from app.classes.customer import Customer_Customer
|
||||
|
||||
from app.classes.employee import Employee_Employee
|
||||
from app.classes.delivery import Delivery_Delivery
|
||||
|
||||
|
||||
@@ -20,7 +15,7 @@ def oil_total_gallons():
|
||||
.group_by(Delivery_Delivery.id)\
|
||||
.all()
|
||||
|
||||
return jsonify({"ok": True }), 200
|
||||
return jsonify({"ok": True, "oil": total_oil }), 200
|
||||
|
||||
@reports.route("/customers/list", methods=["GET"])
|
||||
def customer_list():
|
||||
|
||||
Reference in New Issue
Block a user