window和linux下html调用本地可执行文件

本文介绍了如何在Windows和Linux环境下,通过HTML页面调用本地的可执行文件,并且提供了在Flask服务器环境下使用的示例。
摘要由CSDN通过智能技术生成

html 打开本地可执行文件

windows设置

#coding=utf-8
import _winreg

path = u'C:\\FFM_FTP\\ffm_ftp.exe'

#必须以管理员身份运行
class createKey():
    def __init__(self):
        key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "FFM")
        key_shell = _winreg.CreateKeyEx(key, 'shell', 0, _winreg.REG_CREATED_NEW_KEY)
        key_shell_open = _winreg.CreateKeyEx(key_shell, 'open', 0, _winreg.REG_CREATED_NEW_KEY)

        # 创建数值的名称和值
        _winreg.SetValueEx(key, 'URL Protocol', 0, _winreg.REG_CREATED_NEW_KEY, u'URL:Go Protocol Handler')  # 设置项中:创建数值的名称和值
        _winreg.SetValue(key, 'Defaultlcon', _winreg.REG_CREATED_NEW_KEY,
                         path)  # 创建子项并设置键中默认的名称的值
        _winreg.SetValue(key_shell_open, 'command', _winreg.REG_CREATED_NEW_KEY,
                         path + ' FFM://ffm_ftp')


        _winreg.FlushKey(key)
        _winreg.CloseKey(key)

        print 'set path is ok'

regedit = createKey()

linux设置

#encoding: utf-8

import os
from subprocess import call

desktop = '''
[Desktop Entry]
Name=FFM ftp
GenericName=Text Editor
Comment=Handle URL Scheme ffmftp://
Exec=/usr/local/FFM_FTP/ffm_ftp %u
Terminal=false
Type=Application
MimeType=x-scheme-handler/ffmftp;
Icon=sublime-text-2
Categories=TextEditor;Development;Utility;
Name[en_US]=FFM ftp
'''

handler = '''
#!/usr/bin/env bash

request="${1#*://}"             # Remove schema from url (ffm_ftp://)
request="${request#*?url=}"     # Remove open?url=
request="${request//%2F//}"     # Replace %2F with /
r
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值