当我尝试将传入流量重定向到https时,我得到一个无限重定向循环.
@app.route('/checkout/')
def checkout():
checkout = "https://myapp.herokuapp.com/checkout/"
if checkout != request.url:
print checkout, request.url
return redirect(checkout)
return render_template('checkout.html', key=keys['publishable_key'])
Run Code Online (Sandbox Code Playgroud)
request.url永远不会更改为前缀https.我想使用heroku的搭载ssl来降低成本.
我有一个由Parsec制作的haskell抽象语法树.我希望能够在同时遍历它时查询其结构,以便将其转换为中间代码.例如,我需要知道我的AST的任何给定函数有多少参数才能进行这种转换.我目前正在做的是将AST传递给每个函数,所以每当我需要进行查找时我都可以调用它,并且我在另一个文件中有辅助函数来为我执行查找.这污染了我的类型签名.特别是当我开始添加更多东西,如累加器.
而不是将AST传递给我听过的每个函数,这对于Reader Monad(对于不改变的状态,AST)和状态Monad(对于确实改变的状态,累加器)来说是一个好工作.
如何从IO monad(gulp)中取出ast 并在Reader Monad中使用它来进行全局查找?
main = do
putStrLn "Please enter the name of your jack file (i.e. Main)"
fileName <- getLine
file <- readFile (fileName++".jack")
let ast = parseString file
writeFile (fileName++".xml") (toClass ast) --I need to query this globally
putStrLn $ "Completed Parsing, " ++ fileName ++ ".vm created..."
type VM = String
toClass :: Jack -> VM
toClass c = case c of
(Class ident decs) ->
toDecs decs
toDecs ::[Declaration] -> VM …Run Code Online (Sandbox Code Playgroud) 在全新安装haskell-platform(via homebrew)(GHC x64 7.6.3)OSX 10.9.2时,我在运行时收到以下警告ghc-pkg check(见下文)
Warning: haddock-interfaces: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/ghc-mod-3.1.7/html/ghc-mod.haddock doesn't exist or isn't a file
Warning: haddock-html: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/ghc-mod-3.1.7/html doesn't exist or isn't a directory
Warning: haddock-interfaces: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/hlint-1.8.59/html/hlint.haddock doesn't exist or isn't a file
Warning: haddock-html: /Users/user/.cabal/share/doc/x86_64-osx-ghc-7.6.3/hlint-1.8.59/html doesn't exist or isn't a directory
Warning: haddock-html: /usr/local/Cellar/haskell-platform/2013.2.0.0/share/doc/mtl-2.1.2/html doesn't exist or isn't a directory
Warning: haddock-interfaces: /usr/local/Cellar/haskell-platform/2013.2.0.0/share/doc/transformers-0.3.0.0/html/transformers.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/local/Cellar/haskell-platform/2013.2.0.0/share/doc/transformers-0.3.0.0/html doesn't exist or isn't a directory
Warning: haddock-interfaces: /usr/local/Cellar/haskell-platform/2013.2.0.0/share/doc/case-insensitive-1.0.0.1/html/case-insensitive.haddock doesn't …Run Code Online (Sandbox Code Playgroud) 我正在抓取推文并将它们插入到mongo数据库中以便在python中进行分析工作.我想查看我的数据库的大小,这样如果我在亚马逊上运行,我就不会产生额外的费用.我怎么知道我目前的mongo数据库在osx上有多大?免费套餐会覆盖我吗?
我正在尝试使用mysql-flask python扩展来执行一些sql.由于某种原因,下面的代码总是返回long.
stringify = lambda x : '"' + x + '"'
if request.method == 'POST':
sql = "select * from users where username = " + stringify(request.form['username'])
user = g.db.cursor().execute(sql).fetchall()
Run Code Online (Sandbox Code Playgroud)
错误:
user = g.db.cursor().execute(sql).fetchall()
AttributeError: 'long' object has no attribute 'fetchall'
Run Code Online (Sandbox Code Playgroud)
为什么不返回结果集?
另外,我可以很好地执行insert语句.
修复(答案):
def get_data(g, sql):
cursor = g.db.cursor()
cursor.execute(sql)
data = [dict((cursor.description[idx][0], value) for idx, value in enumerate(row)) for row in cursor.fetchall()]
return data
Run Code Online (Sandbox Code Playgroud) 我在这个URL上有一个示例Web应用程序(在heroku上运行flask-login的烧瓶):http://twittaclone.herokuapp.com.
当我在我的localhost上运行它时,登录功能正常.当我推送到heroku时它会吓坏并且不允许用户登录(它允许用户注册).正在进行数据库修改.
为什么烧瓶登录不能在heroku上运行?
app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_DATABASE_HOST'] = os.environ['MYSQL_DATABASE_HOST'] if 'MYSQL_DATABASE_HOST' in os.environ else config.MYSQL_DATABASE_HOST
app.config['MYSQL_DATABASE_PORT'] = os.environ['MYSQL_DATABASE_PORT'] if 'MYSQL_DATABASE_PORT' in os.environ else config.MYSQL_DATABASE_PORT
app.config['MYSQL_DATABASE_USER'] = os.environ['MYSQL_DATABASE_USER'] if 'MYSQL_DATABASE_USER' in os.environ else config.MYSQL_DATABASE_USER
app.config['MYSQL_DATABASE_PASSWORD'] = os.environ['MYSQL_DATABASE_PASSWORD'] if 'MYSQL_DATABASE_PASSWORD' in os.environ else config.MYSQL_DATABASE_PASSWORD
app.config['MYSQL_DATABASE_DB'] = os.environ['MYSQL_DATABASE_DB'] if 'MYSQL_DATABASE_DB' in os.environ else config.MYSQL_DATABASE_DB
mysql.init_app(app)
if 'SECRET_KEY' in os.environ: app.config['SECRET_KEY'] = os.environ['SECRET_KEY']
else: app.config['SECRET_KEY'] = os.urandom(24)
def connect_db(): return mysql.connect()
###
# Routing for your application. …Run Code Online (Sandbox Code Playgroud) 我正在建立一个网站,用户可以将文件直接上传到亚马逊s3.我暂时用我的密钥签署一个网址,授予用户临时PUT访问我的网站的权限.这可以通过CORS配置实现.
现在,一旦文件在那里,我希望没有人阅读它们,但我.当前的存储桶策略我不允许每个人阅读包括我,管理员在内的对象.哪个不好.什么桶政策会帮助我?
这是我的工作CORS.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://url.com</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
更新:使用此政策:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Deny",
"NotPrincipal": {
"AWS":"arn:aws:iam::123456789012:user/Bob"
}
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<bucket>/*"
}
]
}
Run Code Online (Sandbox Code Playgroud) 我在C#中有一个char数组.
var arr = new char[3] { 'a','b','c' };
Run Code Online (Sandbox Code Playgroud)
如何在不创建新数组的情况下在其末尾添加空格?
结果: arr = { 'a', 'b', 'c', ' ', ' ', ' ' };
这可能听起来类似于VB.NET ReDim.但我不确定这也是我想要的.我想保留其中的元素,而不是在幕后实例化一个新数组.
这只适用于Generic Collections和ArrayList吗?
谢谢
是否可以使用 python boto 将弹性 IP 地址与 ec2 实例相关联?我正在尝试自动化部署。我在 ec2 部分搜索了 api 文档,但一无所获。