Toggle navigation
Toggle navigation
This project
Loading...
Sign in
万朱浩
/
Venue-Ops
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
戒酒的李白
2025-03-21 19:38:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c9fe3312a8857ca9808d4e6bb79860532af9859b
c9fe3312
1 parent
d4d22f72
Add spider and workflow visualization module entries and related route configurations.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
17 deletions
app.py
views/page/templates/base_page.html
views/workflow_api.py
app.py
View file @
c9fe331
...
...
@@ -83,11 +83,12 @@ app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(hours=2)
from
views.page
import
page
from
views.user
import
user
from
views.spider_control
import
spider_bp
from
views.workflow_api
import
workflow_bp
from
views.workflow_api
import
workflow_bp
,
workflow_api_bp
app
.
register_blueprint
(
page
.
pb
)
app
.
register_blueprint
(
user
.
ub
)
app
.
register_blueprint
(
spider_bp
)
app
.
register_blueprint
(
workflow_bp
)
# 注册工作流蓝图
app
.
register_blueprint
(
workflow_api_bp
)
# 注册工作流API蓝图
# 首页路由
@app.route
(
'/'
)
...
...
views/page/templates/base_page.html
View file @
c9fe331
...
...
@@ -115,6 +115,26 @@
<span
class=
"ml-2"
data-i18n=
"yuqingpredict"
>
舆情预测
</span>
</a>
</li>
<li
class=
"sidebar-layout"
>
<a
href=
"/spider/control"
class=
"svg-icon"
>
<i
class=
""
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"18"
fill=
"none"
viewbox=
"0 0 24 24"
stroke=
"currentColor"
>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"2"
d=
"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
></path>
</svg>
</i>
<span
class=
"ml-2"
data-i18n=
"spiderControl"
>
爬虫可视化控制
</span>
</a>
</li>
<li
class=
"sidebar-layout"
>
<a
href=
"/workflow/editor"
class=
"svg-icon"
>
<i
class=
""
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"18"
fill=
"none"
viewbox=
"0 0 24 24"
stroke=
"currentColor"
>
<path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"2"
d=
"M13 10V3L4 14h7v7l9-11h-7z"
></path>
</svg>
</i>
<span
class=
"ml-2"
data-i18n=
"workflowEditor"
>
流程可视化编排
</span>
</a>
</li>
<li
class=
" sidebar-layout"
>
<a
href=
"/page/articleCloud"
class=
"svg-icon"
>
<i
class=
""
>
...
...
views/workflow_api.py
View file @
c9fe331
...
...
@@ -4,18 +4,27 @@ import time
import
uuid
import
logging
from
datetime
import
datetime
,
timedelta
from
flask
import
Blueprint
,
request
,
jsonify
,
current_app
from
flask
import
Blueprint
,
request
,
jsonify
,
current_app
,
render_template
from
utils.db_manager
import
DatabaseManager
from
utils.sensitive_filter
import
filter_dict
from
utils.cache_manager
import
CacheManager
workflow_bp
=
Blueprint
(
'workflow'
,
__name__
,
url_prefix
=
'/api/workflow'
)
# 创建两个蓝图:一个用于页面渲染,一个用于API
workflow_bp
=
Blueprint
(
'workflow'
,
__name__
,
url_prefix
=
'/workflow'
)
workflow_api_bp
=
Blueprint
(
'workflow_api'
,
__name__
,
url_prefix
=
'/api/workflow'
)
logger
=
logging
.
getLogger
(
'workflow_api'
)
logger
.
setLevel
(
logging
.
INFO
)
# 缓存管理器
workflow_cache
=
CacheManager
(
name
=
"workflows"
,
memory_capacity
=
100
,
cache_duration
=
1
)
# 添加工作流编辑器页面路由
@workflow_bp.route
(
'/editor'
,
methods
=
[
'GET'
])
def
workflow_editor
():
"""渲染工作流编辑器页面"""
return
render_template
(
'workflow_editor.html'
)
# 默认爬虫配置模板
DEFAULT_CRAWLER_TEMPLATES
=
[
{
...
...
@@ -363,7 +372,7 @@ AVAILABLE_COMPONENTS = {
]
}
@workflow_bp.route
(
'/crawler-templates'
,
methods
=
[
'GET'
])
@workflow_
api_
bp.route
(
'/crawler-templates'
,
methods
=
[
'GET'
])
def
get_crawler_templates
():
"""获取爬虫配置模板列表"""
# 从缓存获取
...
...
@@ -392,7 +401,7 @@ def get_crawler_templates():
'data'
:
filter_dict
(
templates
)
})
@workflow_bp.route
(
'/crawler-templates/<template_id>'
,
methods
=
[
'GET'
])
@workflow_
api_
bp.route
(
'/crawler-templates/<template_id>'
,
methods
=
[
'GET'
])
def
get_crawler_template
(
template_id
):
"""获取指定爬虫配置模板"""
# 查找默认模板
...
...
@@ -425,7 +434,7 @@ def get_crawler_template(template_id):
'data'
:
filter_dict
(
template
)
})
@workflow_bp.route
(
'/crawler-templates'
,
methods
=
[
'POST'
])
@workflow_
api_
bp.route
(
'/crawler-templates'
,
methods
=
[
'POST'
])
def
create_crawler_template
():
"""创建爬虫配置模板"""
data
=
request
.
json
...
...
@@ -491,7 +500,7 @@ def create_crawler_template():
finally
:
cursor
.
close
()
@workflow_bp.route
(
'/crawler-templates/<template_id>'
,
methods
=
[
'PUT'
])
@workflow_
api_
bp.route
(
'/crawler-templates/<template_id>'
,
methods
=
[
'PUT'
])
def
update_crawler_template
(
template_id
):
"""更新爬虫配置模板"""
data
=
request
.
json
...
...
@@ -552,7 +561,7 @@ def update_crawler_template(template_id):
finally
:
cursor
.
close
()
@workflow_bp.route
(
'/crawler-templates/<template_id>'
,
methods
=
[
'DELETE'
])
@workflow_
api_
bp.route
(
'/crawler-templates/<template_id>'
,
methods
=
[
'DELETE'
])
def
delete_crawler_template
(
template_id
):
"""删除爬虫配置模板"""
# 验证模板是否存在
...
...
@@ -597,7 +606,7 @@ def delete_crawler_template(template_id):
finally
:
cursor
.
close
()
@workflow_bp.route
(
'/analysis-templates'
,
methods
=
[
'GET'
])
@workflow_
api_
bp.route
(
'/analysis-templates'
,
methods
=
[
'GET'
])
def
get_analysis_templates
():
"""获取分析流程模板列表"""
# 从缓存获取
...
...
@@ -626,7 +635,7 @@ def get_analysis_templates():
'data'
:
filter_dict
(
templates
)
})
@workflow_bp.route
(
'/analysis-templates/<template_id>'
,
methods
=
[
'GET'
])
@workflow_
api_
bp.route
(
'/analysis-templates/<template_id>'
,
methods
=
[
'GET'
])
def
get_analysis_template
(
template_id
):
"""获取指定分析流程模板"""
# 查找默认模板
...
...
@@ -659,7 +668,7 @@ def get_analysis_template(template_id):
'data'
:
filter_dict
(
template
)
})
@workflow_bp.route
(
'/analysis-templates'
,
methods
=
[
'POST'
])
@workflow_
api_
bp.route
(
'/analysis-templates'
,
methods
=
[
'POST'
])
def
create_analysis_template
():
"""创建分析流程模板"""
data
=
request
.
json
...
...
@@ -727,7 +736,7 @@ def create_analysis_template():
finally
:
cursor
.
close
()
@workflow_bp.route
(
'/analysis-templates/<template_id>'
,
methods
=
[
'PUT'
])
@workflow_
api_
bp.route
(
'/analysis-templates/<template_id>'
,
methods
=
[
'PUT'
])
def
update_analysis_template
(
template_id
):
"""更新分析流程模板"""
data
=
request
.
json
...
...
@@ -790,7 +799,7 @@ def update_analysis_template(template_id):
finally
:
cursor
.
close
()
@workflow_bp.route
(
'/analysis-templates/<template_id>'
,
methods
=
[
'DELETE'
])
@workflow_
api_
bp.route
(
'/analysis-templates/<template_id>'
,
methods
=
[
'DELETE'
])
def
delete_analysis_template
(
template_id
):
"""删除分析流程模板"""
# 验证模板是否存在
...
...
@@ -835,7 +844,7 @@ def delete_analysis_template(template_id):
finally
:
cursor
.
close
()
@workflow_bp.route
(
'/components'
,
methods
=
[
'GET'
])
@workflow_
api_
bp.route
(
'/components'
,
methods
=
[
'GET'
])
def
get_available_components
():
"""获取可用组件列表"""
return
jsonify
({
...
...
@@ -843,7 +852,7 @@ def get_available_components():
'data'
:
filter_dict
(
AVAILABLE_COMPONENTS
)
})
@workflow_bp.route
(
'/run-workflow'
,
methods
=
[
'POST'
])
@workflow_
api_
bp.route
(
'/run-workflow'
,
methods
=
[
'POST'
])
def
run_workflow
():
"""执行工作流"""
data
=
request
.
json
...
...
@@ -874,7 +883,7 @@ def run_workflow():
}
})
@workflow_bp.route
(
'/task-status/<task_id>'
,
methods
=
[
'GET'
])
@workflow_
api_
bp.route
(
'/task-status/<task_id>'
,
methods
=
[
'GET'
])
def
get_task_status
(
task_id
):
"""获取任务执行状态"""
# 这里是获取任务状态的占位符
...
...
@@ -893,4 +902,19 @@ def get_task_status(task_id):
return
jsonify
({
'success'
:
True
,
'data'
:
status
})
\ No newline at end of file
})
@workflow_api_bp.route
(
'/save'
,
methods
=
[
'POST'
])
def
save_workflow
():
"""保存工作流"""
# ... existing code ...
@workflow_api_bp.route
(
'/<workflow_id>'
,
methods
=
[
'GET'
])
def
get_workflow
(
workflow_id
):
"""获取工作流"""
# ... existing code ...
@workflow_api_bp.route
(
'/<workflow_id>'
,
methods
=
[
'DELETE'
])
def
delete_workflow
(
workflow_id
):
"""删除工作流"""
# ... existing code ...
\ No newline at end of file
...
...
Please
register
or
login
to post a comment