test front

This commit is contained in:
Kseninia Mikhaylova 2024-11-20 14:53:43 +03:00
parent 798fc92f21
commit 768bea9967
12 changed files with 9709 additions and 0 deletions

View File

@ -19,4 +19,6 @@ RUN poetry install
COPY . ${WORKING_DIR} COPY . ${WORKING_DIR}
RUN cd front && npm install && npm run generate
RUN cd ..
CMD poetry run uvicorn app.main:app --host 0.0.0.0 --port 80 CMD poetry run uvicorn app.main:app --host 0.0.0.0 --port 80

View File

@ -5,9 +5,12 @@ from datetime import datetime
import locale import locale
from urllib.parse import parse_qs from urllib.parse import parse_qs
from pathlib import Path
from fastapi import FastAPI, Request from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse
from app.constants import * from app.constants import *
@ -198,3 +201,25 @@ async def deal_tab(
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
return {"status": "error"} return {"status": "error"}
# app.mount("/widget", StaticFiles(directory="front/dist", html=True), name="static")
NUXT_DIST = Path("front/dist")
@app.post("/widget")
async def handle_widget_post(request: Request):
# Обработка данных POST-запроса
# data = await request.json()
# Загружаем сгенерированный HTML (например, index.html)
body = await request.body()
b_str = body.decode()
result = parse_qs(b_str)
logger.info(result)
html_file = NUXT_DIST / "index.html"
if html_file.exists():
html_content = html_file.read_text()
return HTMLResponse(content=html_content, status_code=200)
return {"error": "Nuxt.js page not found"}, 404

24
front/.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.example

75
front/README.md Normal file
View File

@ -0,0 +1,75 @@
# Nuxt Minimal Starter
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm dev
# yarn
yarn dev
# bun
bun run dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm build
# yarn
yarn build
# bun
bun run build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm preview
# yarn
yarn preview
# bun
bun run preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

6
front/app.vue Normal file
View File

@ -0,0 +1,6 @@
<template>
<div>
<NuxtRouteAnnouncer />
<NuxtWelcome />
</div>
</template>

10
front/nuxt.config.ts Normal file
View File

@ -0,0 +1,10 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
app: {
baseURL: '/widget/', // Базовый путь
// buildAssetsDir: '/widget/_nuxt/', // Путь для статических файлов
},
})

9542
front/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

17
front/package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"nuxt": "^3.14.1592",
"vue": "latest",
"vue-router": "latest"
}
}

BIN
front/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

1
front/public/robots.txt Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

4
front/tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}