【问题标题】:How to quickly test a page locally如何在本地快速测试页面
【发布时间】:2015-08-10 09:13:08
【问题描述】:

在编写/调试应用时,我需要快速测试页面。只是使用

install()
opencpu$browser("mypage.html") 

还不够,因为页面似乎没有更新。

【问题讨论】:

    标签: r opencpu


    【解决方案1】:

    安装后确实需要重启服务器,否则页面可能不会更新。

    我编写了以下函数,过去几个月我一直在愉快地使用它:

    testApp <- function(page="",port="",pkg=gsub("^.*\\/","",getwd())){
        require("opencpu")
        require("devtools")
        document();
        # install the package
        install();
        # restart the server (or it will display cached things)
        opencpu$stop();
        if(port==""){
            opencpu$start();
        }else{
            opencpu$start(port);
        }
        # visualize
        opencpu$browse(paste0("/library/",pkg,"/www/",page));
    }
    

    然后你可以这样做:

    testApp()
    

    测试index.html

    testApp("mypage.html") 
    

    测试特定页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-03
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 2020-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多