小编Hop*_*ppo的帖子

如何在nginx上托管的单个域下托管多个烧瓶应用程序?

我想要实现的目标:

我有一个托管mydomain.com的nginx web服务器.当有人将我的domain.com键入他们的客户端时,我希望我的服务器能够提供index.html./var/www/mydomain/当他们输入mydomain.com/flaskapp1时,他们应该看到flaskapp1.当他们输入mydomain.com/flaskapp2时,他们应该看到flaskapp2.

我已经设法使用这里的教程http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/获得了一个或另一个烧瓶应用程序但是当试图实现服务两个单独的烧瓶应用程序时遇到困难.当我尝试在浏览器中使用mydomain.co.uk/flaskapp或mydomain.co.uk/flaskapp2访问任一个烧瓶应用程序时,我没有看到烧瓶应用程序,而是收到404消息.

这是我到目前为止:

cat /etc/nginx/sites-available/mydomain.co.uk

server {
       listen 80;

        server_name www.mydomain.co.uk mydomain.co.uk;

        location / {
               root /var/www/html/;
               index index.html index.htm;
        }

        location /flaskapp {
                include uwsgi_params;
                uwsgi_pass unix:/tmp/flaskapp.sock;
        }

         location /flaskapp2 {
              include uwsgi_params;
              uwsgi_pass unix:/tmp/flaskapp2.sock;
         }
 }
Run Code Online (Sandbox Code Playgroud)

上面的conf文件已被sim链接到/etc/nginx/sites-enabled.

cat /etc/uwsgi/apps-available/flaskapp.ini

[uwsgi]
vhost = true
socket = /tmp/flaskapp.sock
venv = /var/www/flaskapp/venv
chdir = /var/www/flaskapp
module = flaskapp
callable = app
Run Code Online (Sandbox Code Playgroud)

cat /etc/uwsgi/apps-available/flaskapp2.ini

[uwsgi]
vhost = true
socket = /tmp/flaskapp2.sock
venv = /var/www/flaskapp2/venv …
Run Code Online (Sandbox Code Playgroud)

nginx flask uwsgi

14
推荐指数
2
解决办法
9193
查看次数

在递归功能的挣扎中,我做错了什么

我对python很新,并且理解递归是一个需要掌握的重要概念.我一直在尝试各种脚本来运用我的知识,并提出以下脚本来模拟抽奖,你只需从49个数字中抽取六个,然后将它们与另外六个进行比较,看看你是否赢了.我正在努力使用递归函数来获取另一个函数的值.

我相信它会很简单,但我自己也无法理解.

到目前为止,这是我的代码:

from random import randint

def drawSix():
    six = []
    while len(six) < 6:
        a = randint(1,49)   
        if a not in six:
            six.append(a)
    return sorted(six)

def lottery(draw,ticket):
    if draw == ticket:
        return 'win'
    return lottery(drawSix(),drawSix())
Run Code Online (Sandbox Code Playgroud)

我用彩票调用函数(drawSix(),drawSix())

并递归地获得以下内容.

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    lottery(drawSix(),drawSix())
  File "/Users/johnhopkins/Desktop/lottery.py", line 14, in lottery
    return lottery(drawSix(),drawSix())
Run Code Online (Sandbox Code Playgroud)

python recursion

1
推荐指数
1
解决办法
252
查看次数

与ViewController中的UITableViewCell和UITableView交谈

我在storyboard视图控制器中设置了一个带有自定义单元格的表视图,并希望从我的ViewController类中控制它.我已经设置了ViewController作为我的委托.当我运行应用程序时,它只显示一个空列表,并且不会调用我的一个有标签的单元格.我希望在列表中看到这个标签.我已将数据源和委托连接到storyboard中的ViewController.我的.h和.m文件如下所示,为简单起见而编辑.

当我运行它时,我得到'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'所以看起来代表团工作不正常.我错过了什么?我需要将电池连接到任何东西吗?

@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

@end



@implementation ViewController
...

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReportItem"];
return cell;
}

@end
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch uitableview ios5

0
推荐指数
1
解决办法
1251
查看次数

标签 统计

cocoa-touch ×1

flask ×1

ios5 ×1

iphone ×1

nginx ×1

python ×1

recursion ×1

uitableview ×1

uwsgi ×1