美文网首页
Mac开启SimpleHTTPServer

Mac开启SimpleHTTPServer

作者: Keep_FighterLS | 来源:发表于2016-05-09 08:57 被阅读1290次

在苹果出的Demo里看到的命令,记录如下

python -m SimpleHTTPServer 9001

问题:怎么可以把 iOS/Android 应用的下载链接合成一个二维码?

我们写一个HTML,命名为ShiXiangTVQR.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ShiXiangTV</title>

</head>
<body>
<div id="Layer1" style="position:relative; width:100%; height:100%; z-index:-1">
    ![](https://img.haomeiwen.com/i669248/f439b4be925c43ba.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
</div>
<script>
    var isMobile = {
        Android: function () {
            return window.navigator.userAgent.match(/Android/i) ? true : false;
        },
        BlackBerry: function () {
            return window.navigator.userAgent.match(/BlackBerry/i) ? true : false;
        },
        iOS: function () {
            return window.navigator.userAgent.match(/iPhone|iPad|iPod|Mac/i) ? true : false;
        },
        Windows: function () {
            return window.navigator.userAgent.match(/IEMobile/i) ? true : false;
        },
       weiXin: function(){
        var ua = navigator.userAgent.toLowerCase();
       if(ua.match(/MicroMessenger/i)=="micromessenger") {
          return true;
       } else {
          return false;
       }
       },
        any: function () {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
        }
    };

    if (isMobile.iOS()) { //判断是否为android,BlackBerry,ios,windows
        //要执行的代码
        window.location="https://itunes.apple.com/cn/app/id1111076875?mt=8";
    }
    if (isMobile.weiXin())
    {
        document.getElementsByTagName('img')[0].setAttribute('src','http://ww4.sinaimg.cn/mw690/ac593e95gw1f3nwbqt95cj20go0gowfc.jpg');
    }
</script>
</body>
</html>

把HTML放在一个文件夹里,这里我们的文件夹名为client,在终端中调到指定目录,开启SimpleHTTPServer,并设置端口为9001,如下图。

SimpleHTTPServer.png

到这一步,已经可以访问本地页面了,可以做些简单测试

http://localhost:9001/ShiXiangTVQR.html  //localhost为有线电脑ip

相关文章

网友评论

      本文标题:Mac开启SimpleHTTPServer

      本文链接:https://www.haomeiwen.com/subject/gcferttx.html