我刚刚开始使用烧瓶,我遇到了麻烦.我正在尝试写一个小博客来习惯这个框架,所以我制作了两个包,一个"auth"和"posts".我通读了Flask文档中的Large Applications部分.
我的目录看起来像这样.
>/root
>>run.py
>>/posts
>>>____init____.py
>>>views.py
>>>/templates
>>>/static
>>/auth
>>>____init____.py
>>>views.py
>>>/templates
>>>/static
Run Code Online (Sandbox Code Playgroud)
run.py看起来像这样:
from flask import Flask
from auth import auth_app
from posts import posts_app
auth_app.run()
posts_app.run()
Run Code Online (Sandbox Code Playgroud)
/posts/__init__.py
而/auth/__init__.py
像这样:
from flask import Flask
auth_app = Flask(__name__)
import auth.views
Run Code Online (Sandbox Code Playgroud)
和views.py看起来像这样:
from auth import auth_app
@auth_app.route('/auth/')
def index():
return "hello auth!"
Run Code Online (Sandbox Code Playgroud)
但每当我运行服务器时,只有localhost/auth /可用,而其他所有内容都提供了404,som我假设帖子应用程序没有运行.
有人可以帮忙吗?
我工作的大学使用Tomcat/Railo服务器来呈现ColdFusion页面.大约6个月(在我被雇用之前)服务器在不同的时间随机崩溃,通常runnign service railo_ctl restart
有固定的问题,但是最近这个问题还没有起作用.
在过去的两周里,我把问题缩小了,我相当确定问题来自Tomcat.我从未使用过Tomcat,所以我不知道从哪里开始.我查看了Catalina.out文件,查看服务器崩溃的时间并发现此错误消息:
Sep 18, 2013 3:17:12 PM org.apache.catalina.core.StandardServer await.
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instanc
Sep 18, 2013 3:17:12 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8888"]
Sep 18, 2013 3:17:13 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 3:17:14 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Sep 18, 2013 3:17:19 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] is still processing a request that has …
Run Code Online (Sandbox Code Playgroud) 我的烧瓶应用程序看起来像这样......
myapp.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run('0.0.0.0')
Run Code Online (Sandbox Code Playgroud)
我的nginx设置
server {
root /home/admin.jeremylspencer.com;
server_name admin.jeremylspencer.com;
location / { try_files $uri @yourapplication; }
location @yourapplication {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
#error_page 404 /404.html;
#error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ /\.ht {
allow all;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我最后重新启动nginx并运行:
sudo uwsgi -s /tmp/uwsgi.sock --module myapp --callable app这是输出
*** Starting uWSGI 1.4.3 (64bit) …
Run Code Online (Sandbox Code Playgroud) 所以我有这个代码:
animals = ['cat', 'dog', 'waffle', 'giraffe', 'turtle']
breakfeast_foods = ['waffle', 'pancake', 'eggs']
for index, item in enumerate(animals):
print item
if item in breakfeast_foods:
animals.pop(index)
Run Code Online (Sandbox Code Playgroud)
由于某种原因,循环打印语句不会打印“长颈鹿”。我不知道为什么,是我缺少什么吗?