我正在创建一个简单的flaskapp,我将在heroku上部署,第一次在heroku上部署python应用程序,据说我是gunicorn的新手.
附加说明:使用虚拟环境.
烧瓶Flask的版本== 0.10.1
gunicorn == 19.3.0
使用'python run.py' 有效
使用'foreman start'我收到以下错误
16:35:44 web.1 | started with pid 4047
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Starting gunicorn 19.3.0
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Listening at: http://0.0.0.0:5000 (4047)
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4047] [INFO] Using worker: sync
16:35:44 web.1 | [2015-03-30 16:35:44 +0000] [4053] [INFO] Booting worker with pid: 4053
16:35:44 web.1 | * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
16:35:44 web.1 | …Run Code Online (Sandbox Code Playgroud) 我编写了一个使用flask-socketio的 Flask 应用程序。我在端口 8000 上运行 Flask 应用程序,在端口 3000 (react-webpack) 上分别运行客户端应用程序。它在开发模式下完美运行(flask 中提供了 Web 服务器)。但是,当尝试使用 uwsgi 运行时,我遇到了问题。下面将详细介绍这些问题和配置。
wsgi.py(保持不变)
from cloud_app import app, sock
if __name__ == "__main__":
sock.run(app,host='0.0.0.0', debug=True, port=8000)
Run Code Online (Sandbox Code Playgroud)
__init__.py(保持不变)
from flask import Flask
from flask_socketio import SocketIO
import secrets
app = Flask(__name__, static_url_path='/static')
app.secret_key = secrets.secret_key
sock = SocketIO(app)
from cloud_app import routes
Run Code Online (Sandbox Code Playgroud)
route.py(保持不变,明显删除实际逻辑)
...
from flask_cors import CORS
cors = CORS(app, resources={r"/*": {"origins": "*"}}, headers=['Content-Type'], expose_headers=['Access-Control-Allow-Origin'], supports_credentials=True)
@app.route('/example')
def example():
return 'example'
@sock.on('connect', namespace='/example') …Run Code Online (Sandbox Code Playgroud) 第一个Activity(EditCycle)调用第二个活动(EditChooseLists)
Intent i=new Intent(EditCycle.this,EditChooseLists.class);
startActivityForResult(i, RESULT_OK);
Run Code Online (Sandbox Code Playgroud)
第二个活动(EditChooseLists)就这样结束了
Toast.makeText(EditChooseLists.this, list.get(position), Toast.LENGTH_SHORT).show();
Intent i=new Intent();
i.putExtra("desc",content);
i.putExtra("content", list.get(position));
setResult(RESULT_OK,i);
finish();
Run Code Online (Sandbox Code Playgroud)
第一个Activity(EditCycle)将onActivityResult方法重写为this
@Override
public void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode, resultCode, data);
System.out.print("Test Result !");
String content=data.getExtras().getString("content");
System.out.println("result String"+content);
Toast.makeText(EditCycle.this,content, Toast.LENGTH_SHORT).show();
TextView t=(TextView)findViewById(R.id.tv_editcycle_cropLbl);
t.setText(content);
}
Run Code Online (Sandbox Code Playgroud)
然而,当第二个活动恢复时没有任何反应,控制台中没有任何东西,没有吐司,文本视图不变
我的结论是onActivityResult然后没有被调用
有人可以帮忙吗?
在日食中遇到问题说
The project was not built due to "A resource exists with a different case:
'/AgriExpenseTT/bin/classes/uwi/dcit/agriexpensett'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent
Run Code Online (Sandbox Code Playgroud)
我读过其他帖子说要检查我的包名/删除我的R.java/删除bin文件夹/清理项目/重启eclipse和/或计算机,我已经尝试了所有但是无济于事,但是我注意到了在我的bin/classes/uwi/dcit/agriexpensett中没有类文件,如果我有错误应该发生,任何帮助表示赞赏谢谢
给定文件结构并使用WAMP
www
application
\views
\templates
header.php
assets
\js
index.js
\css
index.css
Run Code Online (Sandbox Code Playgroud)
我试图遵循此解决方案中给出的示例Codeigniter:如何包括javascript文件,但是我一直没有成功。
header.php
<html>
<head>
<?php $this->load->helper('url');?>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/index.js" ></script>
<title>CodeIgniter Tutorial</title>
</head>
<body>
<h1><?php echo $title ?></h1>
Run Code Online (Sandbox Code Playgroud)
在浏览器中抛出的错误是
GET http://localhost/index.php/localhost/assets/js/index.js 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)
header.php被调用,因为它是我唯一的带有js参考的php文件,抱歉,如果我误解了其他人的解决方案,我真的不明白为什么它不起作用
前端运行于localhost:3000
服务器运行于localhost:9000
我可以在不访问 cookie 的情况下发出 CORS 请求。
示例 Axios 请求
axios.post(SERVER+'/createUser', params)
.then( resp=>{
//not important
});
Run Code Online (Sandbox Code Playgroud)
(工作:能够从其他服务器访问资源)
我无法保存/发送服务器localhost:9000设置的 HttpOnly cookie [会话实现]
预期流程
拨电至 localhost:9000/authenticate
localhost:9000/authenticate 返回带有 HttpOnly cookie 的响应
localhost:9000携带此 cookie 的后续请求
为了尝试使用 axios 访问此 cookie,我添加了axios 文档withCredentials:true
引用的标头。为清楚起见:
let headers = {
withCredentials:true
}
export function authenticate(creds){
return dispatch => {
axios.post(SERVER+'/authenticate', creds, headers)
.then( resp => {
//not important
});
};
}
Run Code Online (Sandbox Code Playgroud)
之后我收到以下错误:
加载http://localhost:9000/authenticate失败:对预检请求的响应未通过访问控制检查:响应中“Access-Control-Allow-Origin”标头的值不能是通配符“*”当请求的凭据模式为“包含”时。因此,不允许访问Origin ' http://localhost:3000 '。XMLHttpRequest 发起的请求的凭证模式由 withCredentials …