0

我创建了一个具有以下结构的 Flask 应用程序:

/nhs-listpull
/listpull
    /static
    /templates
    __init__.py
    models.py
    views.py
app.db
config.py
run.py

运行.py

from listpull import app
app.run(debug=True)

/listpull/__init__.py

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from mom.client import SQLClient
from smartfocus.restclient import RESTClient

app = Flask(__name__)
app.config.from_object('config')

db = SQLAlchemy(app)
...

/listpull/views.py

import logging
import time
from flask import request, render_template, flash, redirect, send_file
from zlib import compress, decompress
from StringIO import StringIO


@app.route('/')
def index():
    ... do stuff ...
    return render_template('jobs.html', jobs=jobs)

当我运行./run.pyweb 服务器启动时,但浏览返回 404。

知道为什么吗?

4

1 回答 1

0

listpull/views.py永远不会导入,因此不会注册任何路线。您需要将其导入__init__.py文件中(注意循环导入):

...

app = Flask(__name__)
app.config.from_object('config')

db = SQLAlchemy(app)

...

import listpull.views
于 2013-10-10T19:33:33.023 回答