debug page starter

This commit is contained in:
hay-kot 2021-02-10 22:45:24 -09:00
commit 9f84bbaac7
7 changed files with 111 additions and 18 deletions

View file

@ -5,6 +5,7 @@ const prefix = baseURL + "debug";
const debugURLs = {
version: `${prefix}/version`,
lastRecipe: `${prefix}/last-recipe-json`,
};
export default {
@ -12,4 +13,8 @@ export default {
let response = await apiReq.get(debugURLs.version);
return response.data;
},
async getLastJson() {
let response = await apiReq.get(debugURLs.lastRecipe);
return response.data;
},
};

View file

@ -0,0 +1,38 @@
<template>
<v-card>
<v-card-title>Last Scrapped JSON Data</v-card-title>
<v-card-text>
<VJsoneditor
@error="logError()"
v-model="lastRecipeJson"
height="1500px"
:options="jsonEditorOptions"
/>
</v-card-text>
</v-card>
</template>
<script>
import VJsoneditor from "v-jsoneditor";
import api from "@/api";
export default {
components: { VJsoneditor },
data() {
return {
lastRecipeJson: {},
jsonEditorOptions: {
mode: "code",
search: false,
mainMenuBar: false,
},
};
},
async mounted() {
this.lastRecipeJson = await api.meta.getLastJson();
},
};
</script>
<style>
</style>

View file

@ -0,0 +1,37 @@
<template>
<v-card>
<v-card-title>Last Scrapped JSON Data</v-card-title>
<v-card-text>
<VJsoneditor
@error="logError()"
v-model="lastRecipeJson"
height="1500px"
:options="jsonEditorOptions"
/>
</v-card-text>
</v-card>
</template>
<script>
import VJsoneditor from "v-jsoneditor";
export default {
components: { VJsoneditor },
data() {
return {
lastRecipeJson: "",
jsonEditorOptions: {
mode: "code",
search: false,
mainMenuBar: false,
},
};
},
async mounted() {
this.lastRecipeJson = "Hello \n 123 \n 567"
},
};
</script>
<style>
</style>

View file

@ -0,0 +1,20 @@
<template>
<div>
<LastRecipe />
<LogFile class="mt-2" />
</div>
</template>
<script>
import LastRecipe from "@/components/Debug/LastRecipe";
import LogFile from "@/components/Debug/LogFile";
export default {
components: {
LastRecipe,
LogFile,
},
};
</script>
<style>
</style>

View file

@ -7,12 +7,14 @@ import SettingsPage from "./pages/SettingsPage";
import AllRecipesPage from "./pages/AllRecipesPage";
import CategoryPage from "./pages/CategoryPage";
import MeaplPlanPage from "./pages/MealPlanPage";
import Debug from "./pages/Debug";
import MealPlanThisWeekPage from "./pages/MealPlanThisWeekPage";
import api from "@/api";
export const routes = [
{ path: "/", component: HomePage },
{ path: "/mealie", component: HomePage },
{ path: "/debug", component: Debug },
{ path: "/search", component: SearchPage },
{ path: "/recipes/all", component: AllRecipesPage },
{ path: "/recipes/:category", component: CategoryPage },

View file

@ -3,22 +3,12 @@ from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
# import utils.startup as startup
from app_config import APP_VERSION, PORT, PRODUCTION, WEB_PATH, docs_url, redoc_url
from routes import (
backup_routes,
debug_routes,
meal_routes,
migration_routes,
setting_routes,
static_routes,
theme_routes,
)
from routes.recipe import (
all_recipe_routes,
category_routes,
recipe_crud_routes,
tag_routes,
)
from app_config import (APP_VERSION, PORT, PRODUCTION, WEB_PATH, docs_url,
redoc_url)
from routes import (backup_routes, debug_routes, meal_routes, migration_routes,
setting_routes, static_routes, theme_routes)
from routes.recipe import (all_recipe_routes, category_routes,
recipe_crud_routes, tag_routes)
from services.settings_services import default_settings_init
from utils.logger import logger
@ -92,6 +82,7 @@ if __name__ == "__main__":
port=PORT,
reload=True,
debug=True,
log_level="info",
workers=1,
forwarded_allow_ips="*",
)

View file

@ -22,7 +22,7 @@ async def get_last_recipe_json():
return json.loads(f.read())
@router.get("/log/{num}", response_class=HTMLResponse)
@router.get("/log/{num}")
async def get_log(num: int):
""" Doc Str """
with open(LOGGER_FILE, "rb") as f:
@ -53,4 +53,4 @@ def tail(f, lines=20):
block_end_byte -= BLOCK_SIZE
block_number -= 1
all_read_text = b"".join(reversed(blocks))
return b"<br/>".join(all_read_text.splitlines()[-total_lines_wanted:])
return b"/n".join(all_read_text.splitlines()[-total_lines_wanted:])