Commit 4c27f841 authored by wanli's avatar wanli

feat(view/api): 新增evue解析为字节码文件接口

parent 65cb9a19
......@@ -27,6 +27,7 @@ config = dict(
UPLOAD_SERVER="{}://{}:{}/".format(conf.get('uploads', 'protocol'), conf.get('uploads', 'host'), conf.get('uploads', 'port')),
EPK_DIR=conf.get('uploads', 'epk_dir'),
TEMP_DIR=conf.get('uploads', 'temp_dir'),
BYTECODE_DIR=conf.get('application', 'bytecode_dir'),
UPLOAD_PATH=os.path.abspath(conf.get('uploads', 'upload_path')),
UPLOAD_DIR=conf.get('uploads', 'upload_dir'),
TEMPLATE_PATH=os.path.join(os.getcwd(), "static"),
......
......@@ -9,7 +9,6 @@ FilePath: \evm-store\backend\controller\__init__.py
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import logging
from app import signalManager
from .api_manager import apiManager
from .user_manager import userManager
......@@ -22,8 +21,6 @@ from .app_logs_manager import appLogsManager
from .build_logs_manager import buildLogsManager
from .monitor import monitorManager
logger = logging.getLogger(__name__)
def initConnect():
# 系统模块
signalManager.actionApplicationBuild.connect(appsManager.build)
......
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['deploy.py'],
pathex=['F:\\Wanli\\projects\\kxpms\\backend'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='deploy',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False )
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,6 @@ import sys
import os
import signal
import json
# import tornado.autoreload
from tornado.wsgi import WSGIContainer
from tornado.web import Application, RequestHandler, FallbackHandler
from tornado.ioloop import IOLoop
......
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['start.py'],
pathex=['F:\\Wanli\\projects\\kxpms\\backend'],
binaries=[],
datas=[],
hiddenimports=['pony', 'pony.orm.dbproviders', 'pony.orm.dbproviders.sqlite'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='start',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
<html>
<div style="width: 240px;height: 240px;border-width: 1px;border-style: solid;background-color: black;left: 0px;top: 0px;margin: 0px;padding: 0px;">
<div style="padding: 30px; width: 80px;height: 80px; left: 35px;top: 35px; opacity: 0; border-width: 10px; border-radius: 0px; border-color: white; background-color: red;">
<text style="width: 60px;left: 10px;top: 20px; padding: 0px; border-width: 2px; border-color: red; background-color: green; color:white; text-align: left;">hello</text>
</div>
<div style="width: 80px;height: 80px; left: 120px;top: 35px; opacity: 0.4; border-width: 2px; border-radius: 2px; border-color: gray; background-color: red;">
<text style="width: 60px;left: 10px;top: 20px; padding: 2px; border-width: 2px; border-color: red;background-color: green; color:white; text-align: center;">EVM</text>
</div>
<div style="width: 80px;height: 80px; left: 35px;top: 120px; opacity: 0.6; border-width: 4px; border-radius: 4px; border-color: gray; background-color: red;">
<text style="width: 60px;left: 10px;top: 20px; padding: 4px; border-width: 2px; border-color: red;background-color: green; color:white; text-align: right;">hello</text>
</div>
<div style="width: 80px;height: 80px; left: 120px;top: 120px; opacity: 0.8; border-width: 8px; border-radius: 8px; border-color: gray; background-color: red;">
<text style="width: 60px;left: 10px;top: 20px; padding: 8px; border-width: 2px; border-color: red;background-color: green; color:white; text-align: left;">EVUE</text>
</div>
</div>
</html>
<script>
export default {
data: {
title: 'show-test-div'
}
}
</script>
<style>
.container {
flex-direction: row;
justify-content: flex-start;
align-items: pretty;
/*flex-wrap: wrap;*/
}
.wrapper {
margin: 0px;
padding: 0px;
}
</style>
\ No newline at end of file
# -*- coding: utf-8 -*-
import sys
sys.path.append("..")
from utils import vbuild
content = vbuild.render("./index.evue")
print(content.html)
print(content.style)
print(content.script)
\ No newline at end of file
This diff is collapsed.
......@@ -2,26 +2,33 @@
# -*- coding: utf_8 -*-
import os
import json
import logging
import shutil
import subprocess
import traceback
import uuid
import time
import zipfile
import sqlite3
from pathlib import Path
from datetime import datetime
from flask import Blueprint, request, json
from werkzeug.utils import secure_filename
from app import config, signalManager
from fullstack.log import logger
from fullstack.login import Auth
from fullstack.response import ResponseCode, response_result
from fullstack.validation import validate_schema
from schema.api import UpdatePasswordSchema, ApplicationBuildSchema, ConvertString
logger = logging.getLogger(__name__)
import sys
sys.path.append("..")
from utils import vbuild
api = Blueprint("api", __name__, url_prefix="/api/v1/%s" % config['NAME'])
logger.info("/api/v1/%s" % config['NAME'])
def stopApp():
fpath = os.sep.join([os.getcwd(), "restart.json"])
with open(fpath, "w+") as f:
......@@ -135,6 +142,60 @@ def action_opqcp():
return response_result(ResponseCode.OK, msg=message)
@api.route("/build", methods=['POST'])
def action_build():
# 接收用户上传的evue文件
# 创建一个文件夹
# 将用户上传文件移动到新创建的文件夹中
# 解析这个evue文件,分别生成3个文件:index.html.bc/index.css.bc/index.js.bc
# 对这三个进行zip压缩,将压缩后的zip链接返回给前端
binfile = request.files.get("binfile")
if not binfile:
return response_result(ResponseCode.REQUEST_ERROR, msg="upload field name error")
target_path = Path(config.get("UPLOAD_PATH")).joinpath(config.get("BYTECODE_DIR"))
if not target_path.exists():
target_path.mkdir()
target_path = target_path.joinpath(uuid.uuid1().hex)
if not target_path.exists():
target_path.mkdir()
target = target_path.joinpath(binfile.filename)
with open(target.resolve().as_posix(), "wb+") as fd:
fd.write(binfile.stream.read())
content = vbuild.render(target.resolve().as_posix())
if content:
files = [
(target.parent.joinpath("{}.hml".format(Path(binfile.filename).stem)).resolve().as_posix(), content.html),
(target.parent.joinpath("{}.css".format(Path(binfile.filename).stem)).resolve().as_posix(), content.style),
(target.parent.joinpath("{}.js".format(Path(binfile.filename).stem)).resolve().as_posix(), content.script)
]
dst_files = []
for item in files:
file, text = item
with open(file, "w+") as fd:
fd.write(text)
result = subprocess.call("./executable -c {file}".format(file=file), shell=True)
logger.info(result)
t = Path(file)
res = t.rename("{}.{}".format(t.name, "bc"))
dst_files.append(res)
zip_filepath = target_path.joinpath("{}.zip".format(target_path.name)).resolve().as_posix()
z = zipfile.ZipFile(zip_filepath, 'w')
for file in dst_files:
z.write(file.resolve().as_posix(), arcname=file.name)
shutil.move(file.resolve().as_posix(), target_path.joinpath(file.name).resolve().as_posix())
z.close()
result = Path(zip_filepath).resolve().relative_to(Path(config.get("UPLOAD_PATH"))).as_posix()
return response_result(ResponseCode.OK, data=result)
@api.route("/monitor", methods=['GET', 'POST'])
def action_monitor():
print(request.json)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment