小编San*_*San的帖子

烧瓶应用与背景线程

我正在创建一个烧瓶应用程序,对于一个请求,我需要运行一些长时间运行的作业,这不需要在UI上等待.我将创建一个线程并向UI发送消息.该线程将计算并更新数据库.但是,UI会在提交时看到一条消息.下面是我的实现,但它正在运行线程,然后将输出发送到UI,这不是我喜欢的.如何在后台运行此线程?

@app.route('/someJob')
def index():
    t1 = threading.Thread(target=long_running_job)
    t1.start()
    return 'Scheduled a job'

def long_running_job
    #some long running processing here
Run Code Online (Sandbox Code Playgroud)

如何让线程t1运行后台并立即发送消息?

multithreading flask

17
推荐指数
3
解决办法
2万
查看次数

Flask静态文件获得404

我正在构建一个具有以下项目结构的基本Web应用程序.该应用程序很好,但我得到一些静态文件的404错误.

我没有像bootstrap.css.map那样的文件,也无法在烧瓶中找到足够的文档.

127.0.0.1 - - [09/Feb/2014 22:37:17] "GET /static/css/bootstrap.css.map HTTP/1.1" 404 -

@app.route('/')
def index():
print 'in /'
return send_file('templates/login.html')
Run Code Online (Sandbox Code Playgroud)

目录结构:

app/
??? static/
?   ??? bootstrap.min.css
??? templates/
?   ??? index.html
??? app.py
Run Code Online (Sandbox Code Playgroud)

编辑:这是我的登录HTML

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<title>API Test Application</title>

<!-- Bootstrap core CSS -->
<link href="/static/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom CSS for the 'Thumbnail Gallery' Template -->
<link href="/static/css/2-col-portfolio.css" rel="stylesheet">
</head>

<body>
 ......simple login form.......... …
Run Code Online (Sandbox Code Playgroud)

python flask twitter-bootstrap

9
推荐指数
1
解决办法
2万
查看次数

具有JUnit testsuite错误的SpringJUnit4ClassRunner

我试图首次使用Spring设置Junit测试套件,并尝试在我的类中进行一些更改,但没有运气并最终出现此错误:"junit.framework.AssertionFailedError:在Myclass中找不到测试"

简而言之,我有两个测试类都来自相同的基类,它加载Spring上下文,如下所示

@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations =
{
"classpath:ApplicationContext.xml"
})
Run Code Online (Sandbox Code Playgroud)

我尝试将这两个测试类添加到一个套件中,如下所示

@RunWith( SpringJUnit4ClassRunner.class )
@SuiteClasses({ OneTest.class, TwoTest.class })
public class MyTestSuite extends TestCase {

//nothing here
}
Run Code Online (Sandbox Code Playgroud)

我从ant运行这个测试套件.但是,这给了我一个错误,说"没有找到测试"但是,如果我从ant运行个别的2个测试用例,它们可以正常工作.不知道为什么会出现这种情况,我肯定在这里遗漏了一些东西.请指教.

ant junit spring

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

执行 org.apache.maven.plugins:maven-resources-plugin:2.6:resources 时缺少 MavenFilteringException

在使用 maven 3.2.5 和本地存储库编译我的项目(在 java6 上)并下载了所有必需的 jar 时,我遇到了异常。该项目使用 maven2.0 构建良好,我们正在升级到 3.2.5。下载了所有必需的依赖 jar,但即使我看到存储库中存在 maven-filtering jar,它仍然会抱怨以下错误。

另外,我尝试了以下选项,但错误仍然相同。我在这里缺少其他任何地方或设置吗?

  • 在 repository-new\org\apache\maven\shared 中复制了 maven-filtering 1.1
  • 在 repository-new\org\apache\maven\shared 中复制了 maven-filtering 3.1.1
  • 清理 .m2 本地缓存
  • 在 repository-new\org\apache\maven\maven-filtering 中复制了 maven-filtering 1.1
  • 在 repository-new\org\apache\maven\maven-filtering 中复制了 maven-filtering 3.1.1

错误堆栈跟踪:

realm =    plugin>org.apache.maven.plugins:maven-resources-plugin:2.6
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/coding/repository-new/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar
urls[1] = file:/C:/repository-new/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355) …
Run Code Online (Sandbox Code Playgroud)

maven-plugin maven-3 maven java-6

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