setup local hosting

This commit is contained in:
ari committed 2022-01-04 23:27:23 -05:00
1 parent 25e65540e1
commit 63cfd936b5
9 files changed
+31 -22

No files matched your search

+1 -1
View File
@@ -43,5 +43,5 @@ clean:
run-local:
rm -f web
ln -s ../web/dist web
ln -s ../webapp/build web
USE_EXAMPLE_REPO=1 uvicorn src.app:app
+11 -8
View File
@@ -7,14 +7,17 @@ from .routes import ping, automations
def make_app(automation_mgr: AutomationManager) -> FastAPI:
app = FastAPI()
# app.mount(
# "/web",
# StaticFiles(
# directory=ROOT_FOLDER / "web",
# html=True,
# ),
# name="web",
# )
if (ROOT_FOLDER / "web").exists():
app.mount(
"/web",
StaticFiles(
directory=ROOT_FOLDER / "web",
html=True,
),
name="web",
)
else:
print("WARN: could not find web folder")
app.include_router(ping.router, prefix="/ping")
app.include_router(automations.make_automation_router(automation_mgr), prefix="/automations")
+1 -1
View File
@@ -1 +1 @@
../web/dist
../webapp/build
+1
View File
@@ -2,6 +2,7 @@
"name": "webapp",
"version": "0.1.0",
"private": true,
"homepage": "/web",
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
-1
View File
@@ -12,7 +12,6 @@ export const makeAutomationAPI = (api: API) => ({
offset, limit,
}
});
console.log({ list: data });
return data;
},
async update({index, auto}: {index: number, auto: AutomationData}) {
+14 -7
View File
@@ -1,4 +1,4 @@
import { APIRequest, APIResponse } from "./types";
import { APIRequest, APIResponse } from './types';
export interface API {
makeCall: <Res = any, Req = any>(req: APIRequest<Req>) => Promise<APIResponse<Res>>;
@@ -9,19 +9,26 @@ export const makeRemoteAPI = (baseURL: string): API => ({
method = "POST",
data={}
}) {
const reply = await fetch(baseURL + "/" + path, {
const reply = await fetch(baseURL + path, {
method,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data),
});
let response: APIResponse<any>;
if (reply.status === 200) {
return {
response = {
ok: true,
data: await reply.json(),
}
} else {
response = {
ok: false,
error: await reply.text(),
}
console.error(response)
}
return {
ok: false,
error: await reply.text(),
}
return response
}
})
+1 -1
View File
@@ -5,7 +5,7 @@ import { useAPIService } from './core';
import {useMockAPI} from "./mock";
export const useConnectedApiService = () => useAPIService(
makeAutomationAPI(makeRemoteAPI("/api/v1"))
makeAutomationAPI(makeRemoteAPI("/automations"))
);
export const useMockApiService = (initialAutos: AutomationData[]) => useAPIService(
makeAutomationAPI(useMockAPI(initialAutos))
+2 -2
View File
@@ -1,4 +1,4 @@
export const AUTOMTAION_ROOT = '/automations' as const;
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}/list` as const;
export const AUTOMTAION_ROOT = '/' as const;
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}list` as const;
@@ -27,7 +27,6 @@ function* dealWithNested(
p2: innerStartLoc,
direction: '1->2',
}
console.log(onRemove)
if (onEdit) {
yield {
type: 'circle',