Python API works now

This commit is contained in:
Shaun Orssaud 2023-11-01 18:11:34 +09:00
parent 033c3e7437
commit 30692fe0db
5 changed files with 17 additions and 15 deletions

View File

@ -10,6 +10,15 @@ CORS(app)
def root(): def root():
return jsonify({'message': 'Welcome to the API!'}) return jsonify({'message': 'Welcome to the API!'})
@app.route('/debug')
def debug():
base_url = request.headers.get('Base-Url')
response = requests.get(
f'{base_url}/api/codex/v1/debug/info'
)
print(response.status_code)
print(response.text)
return response.text
@app.route('/upload', methods=['POST']) @app.route('/upload', methods=['POST'])
def upload(): def upload():

View File

@ -15,8 +15,4 @@ server {
expires 1y; expires 1y;
add_header Cache-Control "public"; add_header Cache-Control "public";
} }
location /uploads {
proxy_pass http://localhost:5000;
}
} }

View File

@ -4,7 +4,8 @@ services:
context: . context: .
dockerfile: Dockerfile.api dockerfile: Dockerfile.api
image: codex-frontend-api image: codex-frontend-api
network_mode: "host" ports:
- "5000:5000"
client: client:
build: build:
context: . context: .

View File

@ -1 +1 @@
REACT_APP_CODEX_URL=http://localhost:8080 REACT_APP_CODEX_URL=http://host.docker.internal:8080

View File

@ -8,6 +8,7 @@ import {
import NodeInfoItemComponent from "../../components/nodeInfoItem/NodeInfoItemComponent"; import NodeInfoItemComponent from "../../components/nodeInfoItem/NodeInfoItemComponent";
import Header from "../../components/layout/partials/Header"; import Header from "../../components/layout/partials/Header";
import { useDexyStore } from "../../store"; import { useDexyStore } from "../../store";
import constants from "../../util/Constants";
function DebugPage() { function DebugPage() {
const { nodeInfo } = useDexyStore(); const { nodeInfo } = useDexyStore();
@ -15,20 +16,15 @@ function DebugPage() {
const [statusInfo, setStatusInfo] = React.useState< const [statusInfo, setStatusInfo] = React.useState<
DebugNodeInfoModel | undefined DebugNodeInfoModel | undefined
>(); >();
useEffect(() => { useEffect(() => {
axios axios
.get( .get(
`${ `${constants.testApiBaseUrl}/debug`,
nodeInfo.nodeToConnectTo || nodeInfo.baseUrl
}/api/codex/v1/debug/info`,
{ {
headers: headers:
(nodeInfo.auth !== null && { ({
Authorization: "Base-Url": nodeInfo.baseUrl,
(nodeInfo.auth && "Basic " + btoa(nodeInfo.auth)) || "", }),
}) ||
{},
} }
) )
.then((response) => { .then((response) => {