加入 pdf 下载脚本处理
This commit is contained in:
parent
0b4e562b96
commit
6da40735f6
@ -1,7 +1,7 @@
|
||||
import gradio as gr
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
import re
|
||||
|
||||
def convert_to_wav(audio_file):
|
||||
# 使用 ffmpeg 将音频文件转换为 wav 格式
|
||||
@ -133,6 +133,14 @@ def convert_to_docx(text):
|
||||
# 返回 file.docx 文件供用户下载
|
||||
return "file.docx"
|
||||
|
||||
def power_shell_pdf_download(powershell_script):
|
||||
# 使用正则表达式去除 if-none-match 和 range 标头
|
||||
powershell_script = re.sub(r'\s*"if-none-match"="`"[^"]*`""\s*', '', powershell_script)
|
||||
powershell_script = re.sub(r'\s*"range"="[^"]*"\s*', '', powershell_script)
|
||||
|
||||
# 在脚本最后加上 "-OutFile 1.pdf"
|
||||
powershell_script = powershell_script.strip() + '\n-OutFile 1.pdf'
|
||||
return powershell_script
|
||||
|
||||
with gr.Blocks() as iface:
|
||||
gr.Markdown("# 大模型工具集")
|
||||
@ -182,6 +190,17 @@ with gr.Blocks() as iface:
|
||||
|
||||
convert_button.click(convert_to_docx, inputs=text_input, outputs=output_file)
|
||||
|
||||
with gr.Tab("下载pdf"):
|
||||
gr.Markdown("## pdf 下载指令修复")
|
||||
with gr.Row():
|
||||
power_shell_text_input = gr.Textbox(lines=15, placeholder="请在此输入power shell 脚本...")
|
||||
with gr.Row():
|
||||
power_shell_pdf_button = gr.Button("转换")
|
||||
with gr.Row():
|
||||
power_shell_text_output = gr.Textbox(lines=15, placeholder="这里会显示结果")
|
||||
|
||||
power_shell_pdf_button.click(power_shell_pdf_download, inputs=power_shell_text_input, outputs=power_shell_text_output)
|
||||
|
||||
iface.load(fn=update_log_output, outputs=[log_output], every=1)
|
||||
|
||||
iface.launch(server_name="0.0.0.0")
|
||||
Loading…
x
Reference in New Issue
Block a user