我试图用字符串值(名称)来识别结构.
reflect.TypeOf回报Type.
但类型断言需要一个type.
我怎样才能铸造Type到type?
或任何处理它的建议?
http://play.golang.org/p/3PJG3YxIyf
package main
import (
"fmt"
"reflect"
)
type Article struct {
Id int64 `json:"id"`
Title string `json:"title",sql:"size:255"`
Content string `json:"content"`
}
func IdentifyItemType(name string) interface{} {
var item interface{}
switch name {
default:
item = Article{}
}
return item
}
func main() {
i := IdentifyItemType("name")
item := i.(Article)
fmt.Printf("Hello, item : %v\n", item)
item2 := i.(reflect.TypeOf(i)) // reflect.TypeOf(i) is not a type
fmt.Printf("Hello, item2 …Run Code Online (Sandbox Code Playgroud) 我在aws弹性beanstalk中遇到自定义配置文件的问题.
我的应用程序是python flask应用程序.
我将01wsgi.config文件放入.ebextensions.
并将其压缩然后上传到弹性豆茎.
源部署得很好,但配置没有执行.
我怎样才能让它正常工作?
目录结构:
source_root
- .ebextensions
-- 01wsgi.config
- application
- application.wsgi
Run Code Online (Sandbox Code Playgroud)
01wsgi.config内容:
files:
"/etc/httpd/conf.d/wsgi.conf":
mode: "000644"
owner: root
group: root
content: |
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/python/run/baselinenv
WSGISocketPrefix run/wsgi
WSGIRestrictEmbedded On
<VirtualHost *:80>
#############
# TYPES FIX #
#############
AddType text/css .css
AddType text/javascript .js
####################
# GZIP COMPRESSION #
####################
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml text/javascript application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] …Run Code Online (Sandbox Code Playgroud) deployment configuration amazon-web-services amazon-elastic-beanstalk
我试图将Web服务部署到Microsoft Azure中。
首先,我从图库中添加了我的网站。
网站->新建->从图库-> Flask
然后Azure生成了一个简单的网站。
后来我将源代码部署到azure网站并管理了web.config文件。
然后我收到如下错误消息。
有人知道如何在Azure网站上使用pip安装python插件吗?
问候,
Error while importing WSGI_HANDLER:
Traceback (most recent call last):
File "D:\Python27\Scripts\wfastcgi.py", line 469, in get_wsgi_handler
handler = getattr(__import__(module, fromlist=[callable]), callable)
File "D:\home\site\wwwroot\wsgi.py", line 17, in <module>
from application import frontend, api_v1
File "D:\home\site\wwwroot\application\frontend\__init__.py", line 14, in <module>
from flask_debugtoolbar import DebugToolbarExtension
ImportError: No module named flask_debugtoolbar
StdOut:
StdErr:
Run Code Online (Sandbox Code Playgroud)