环境搭建配置
This commit is contained in:
BIN
app/blueprints/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/blueprints/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/blueprints/__pycache__/admin.cpython-312.pyc
Normal file
BIN
app/blueprints/__pycache__/admin.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/blueprints/__pycache__/auth.cpython-312.pyc
Normal file
BIN
app/blueprints/__pycache__/auth.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/blueprints/__pycache__/brand.cpython-312.pyc
Normal file
BIN
app/blueprints/__pycache__/brand.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/blueprints/__pycache__/image.cpython-312.pyc
Normal file
BIN
app/blueprints/__pycache__/image.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/blueprints/__pycache__/main.cpython-312.pyc
Normal file
BIN
app/blueprints/__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
@@ -2,7 +2,8 @@
|
||||
主页面蓝图:首页、home、图片工作台、品牌页、静态文件、Logo
|
||||
"""
|
||||
import os
|
||||
from flask import Blueprint, send_file
|
||||
import requests
|
||||
from flask import Blueprint, Response, request, send_file
|
||||
|
||||
from app_common import (
|
||||
get_db,
|
||||
@@ -16,7 +17,9 @@ from app_common import (
|
||||
)
|
||||
from flask import redirect, url_for, session
|
||||
|
||||
from config import base_url,version
|
||||
from config import base_url,version,java_api_base
|
||||
|
||||
JAVA_API_BASE = java_api_base
|
||||
|
||||
main_bp = Blueprint('main', __name__)
|
||||
|
||||
@@ -90,6 +93,36 @@ def serve_new_web_source(filename):
|
||||
|
||||
|
||||
|
||||
@main_bp.route('/newApi/<path:subpath>', methods=['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'])
|
||||
def proxy_new_api(subpath):
|
||||
target_url = f"{JAVA_API_BASE}/{subpath}"
|
||||
try:
|
||||
headers = {
|
||||
key: value
|
||||
for key, value in request.headers.items()
|
||||
if key.lower() not in {'host', 'content-length'}
|
||||
}
|
||||
upstream = requests.request(
|
||||
method=request.method,
|
||||
url=target_url,
|
||||
params=request.args,
|
||||
data=request.get_data(),
|
||||
headers=headers,
|
||||
cookies=request.cookies,
|
||||
allow_redirects=False,
|
||||
timeout=300,
|
||||
)
|
||||
excluded_headers = {'content-encoding', 'content-length', 'transfer-encoding', 'connection'}
|
||||
response_headers = [
|
||||
(name, value)
|
||||
for name, value in upstream.headers.items()
|
||||
if name.lower() not in excluded_headers
|
||||
]
|
||||
return Response(upstream.content, upstream.status_code, response_headers)
|
||||
except requests.RequestException as exc:
|
||||
return {'success': False, 'message': str(exc), 'data': None}, 502
|
||||
|
||||
|
||||
@main_bp.route('/logo.jpg', methods=['GET'])
|
||||
def get_logo_image():
|
||||
return send_file(os.path.join(BASE_DIR, "logo.jpg"), mimetype='image/jpeg')
|
||||
|
||||
Reference in New Issue
Block a user