zoukankan      html  css  js  c++  java
  • 用临时用户数据目录启动Chrome,关闭安全检查等(解决Cross origin requests are only supported for HTTP?)

    Cross origin requests are only supported for HTTP?

    参考:https://www.zhihu.com/question/20948649

    批处理:

    start_chrome_with_tmp_userdata.bat

     1 @echo off
     2 pushd %~dp0
     3 set TMP_USERDATA="%CD%/tmp_userdata"
     4 set TMP_URL="%~1"
     5 if %TMP_URL%=="" goto :help
     6 echo Starting chrome...
     7 "%appdata%..LocalGoogleChromeApplicationchrome.exe" --allow-file-access-from-files --disable-web-security --user-data-dir=%TMP_USERDATA% %TMP_URL%
     8 echo Cleannig tmp dir...
     9 ping 127.1 -n 1 >nul
    10 rd /s /q %TMP_USERDATA% >nul
    11 goto :end
    12 :help
    13 set TMP_CMD=%~n0%~x0
    14 echo Usage:
    15 echo [1] %TMP_CMD% http://www.baidu.com
    16 echo [2] call %TMP_CMD% http://www.baidu.com
    17 echo.
    18 echo Press any key to exit...
    19 pause>nul
    20 :end
    21 popd

    调用例子1:

    @echo off
    call start_chrome_with_tmp_userdata.bat "%CD%video-js-6.6.2/examples/index.html"

    调用例子2:

    C:> start_chrome_with_tmp_userdata.bat http://www.baidu.com

    Python3 启动http

    start_python_web.bat

     1 @echo off
     2 pushd %~dp0
     3 set port=%~1
     4 if "%port%"=="" goto :help
     5 set process_title=%~n0,%port%
     6 echo Kill last process...
     7 taskkill /f /fi "WINDOWTITLE eq %process_title%" > nul
     8 echo Starting python http.server %port%...
     9 start "%process_title%" python -m http.server %port%
    10 goto :end
    11 :help
    12 set TMP_CMD=%~n0%~x0
    13 echo Usage:
    14 echo set port=8081
    15 echo call %TMP_CMD% %%port%%
    16 echo start "" http://localhost:%%port%%
    17 echo.
    18 echo Press any key to exit...
    19 pause>nul
    20 :end
    21 popd

    例子:

    1 @echo off
    2 set port=8081
    3 call start_python_web.bat %port%
    4 ping 127.1 -n 1 >nul
    5 echo Starting demo...
    6 start "" http://localhost:%port%/video-js-6.6.2/examples/simple-embed/h265.html
    7 start "" http://localhost:%port%/libde265.js/demo/libde265_DEMO.html
  • 相关阅读:
    Django上传文件
    Django的模板语言
    LeetCode:268. 缺失数字
    LeetCode:260. 只出现一次的数字 III
    SVN安装使用【转】
    c# 如何给 dataGridView里添加一个自增长列(列名为序号)
    asp.net mvc 使用Ajax调用Action 返回数据【转】
    sql server block如何查询并kill
    软件概要设计文档【转】
    软件详细设计文档【转】
  • 原文地址:https://www.cnblogs.com/Bob-wei/p/8310733.html
Copyright © 2011-2022 走看看