我想在Ubuntu环境中的本地主机上安装SSL证书,因为我不能直接在生产服务器上工作.我必须根据页面是HTTP还是HTTPS在我的代码中加入一些条件.
我怎样才能做到这一点?
我是Mac的新手,但是很长一段时间都在使用Ubuntu进行开发.我知道如何在Ubuntu中创建虚拟主机,但不知道Mac.我创建了hosts
如下条目:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost mysite.loc
255.255.255.255 broadcasthost
::1 localhost
Run Code Online (Sandbox Code Playgroud)
但接下来该怎么办?
我有这个代码:
$tierHosts['host'] = isset($host['name']) ? $host['name'] : $host;
Run Code Online (Sandbox Code Playgroud)
它在PHP 5.5中运行良好,但在PHP 5.3中,条件返回true,同时$host
包含类似的字符串pjba01
.它返回的第一个字母$tierHosts['host']
,即p
.
我的代码出了什么问题?
我通过Create-React-App
以下包(提及与我的问题相关的包)创建了反应项目:
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"typescript": "^3.9.2",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0"
Run Code Online (Sandbox Code Playgroud)
我创建了一个简单的 HOC(现在什么都不做,但我稍后会添加我的逻辑),如下所示:
type Props = {
[key: string]: any;
};
const connect = function (Component: FunctionComponent): FunctionComponent {
const ComponentWrapper = function (props: Props): ReactElement {
return <Component {...props} />;
};
return ComponentWrapper;
};
Run Code Online (Sandbox Code Playgroud)
并像这样导出我的组件:
const Test: FunctionComponent<Props> = function ({ message }: Props) {
return (
<div>{message}</div>
);
};
export default connect(Test);
Run Code Online (Sandbox Code Playgroud)
并像这样使用这个组件:
<Test message="Testing message" />
Run Code Online (Sandbox Code Playgroud)
但是在编译器中出错:
Type '{ message: string; …
Run Code Online (Sandbox Code Playgroud) typescript reactjs create-react-app react-hoc intrinsicattributes
我已经应用了一个具有readonly功能的jquery旋钮,如下所示:
<style>
.test{
background: #292929;
margin:50px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://raw.github.com/aterrien/jQuery-Knob/master/js/jquery.knob.js"></script>
<body>
<input type="text" value="45%" class="dial"><button id="change">Change</button>
</body>
<script>
$(".dial").knob({
readOnly: true,
fgColor: "#00ABC6",
bgColor: "#666666",
thickness: 0.2
});
$(document.body).on('click', 'button#change', function(){
$("input.dial").val('80%');
})
</script>
Run Code Online (Sandbox Code Playgroud)
现在,当我点击更改按钮时,它只会更改输入标签的值,但无法更改旋钮填充区域的百分比.
到目前为止我还没有在我的firefox中安装任何插件,直到现在还没有使用任何额外的js脚本,但我没有从这里content_script.js
启用它并在控制台中打印不必要的消息,如下所示:
content script runtime.onMessage: update_shortcuts
content_script.js (line 91)
<System>
2 content script runtime.onMessage: tabupdate
content_script.js (line 91)
<System>
Run Code Online (Sandbox Code Playgroud)
当我试着查看这个脚本的路径时,它显示了firefox任何插件的一部分:
资源://gre/modules/ExtensionContent.jsm - > moz-extension://22d1d103-e4d1-431c-bc5e-e2fe1cd8d902/javascripts/content_script.js
任何人都可以告诉我这个剧本到底在做什么,我怎么能解除这个......
任何帮助将不胜感激..!!
我想添加错误处理module.php
以在Flash Messenger中添加所有错误消息并重定向到特定页面(根据我的要求):
public function handleError(MvcEvent $e) {
$exception = $e->getParam('exception');
$controller = $e->getTarget();
//echo $exception->getMessage(); exit;
if (!$e->getApplication()->getServiceManager()->get('AuthService')->hasIdentity()) {
$controller->flashMessenger()->addErrorMessage("Session Expired..!!");
return $e->getTarget()->plugin('redirect')->toRoute('auth', array('action' => 'login'));
}
switch ($exception->getCode()) {
case "2003" :
$controller->flashMessenger()->addErrorMessage("Unable to connect database..!!");
break;
default :
$controller->flashMessenger()->addErrorMessage($exception->getMessage());
break;
}
$e->getApplication()->getServiceManager()->get('AuthService')->clearIdentity();
return $e->getTarget()->plugin('redirect')->toRoute('auth', array('action' => 'login'));
}
Run Code Online (Sandbox Code Playgroud)
但是在某些错误中,它会抛出对未定义方法插件的调用,$e->getTarget()
因为在某些情况下,错误是在插件绑定之前生成的。我想要一种redirect and flash messenger plugins
无需引用任何控制器即可访问的方法。
在 Django REST Framework API 中,直到 API 重新启动或 Python 文件(例如模型、序列化程序或视图)中的任何代码更改之前,数据库表记录列表不会更新。我尝试过事务提交,但没有成功。以下是我的看法:
class ServiceViewSet(viewsets.ModelViewSet):
#authentication_classes = APIAuthentication,
queryset = Service.objects.all()
serializer_class = ServiceSerializer
def get_queryset(self):
queryset = self.queryset
parent_id = self.request.QUERY_PARAMS.get('parent_id', None)
if parent_id is not None:
queryset = queryset.filter(parent_id=parent_id)
return queryset
# Make Service readable only
def update(self, request, *args, **kwargs):
return Response(status=status.HTTP_400_BAD_REQUEST)
def destroy(self, request, *args, **kwargs):
return Response(status=status.HTTP_400_BAD_REQUEST)
Run Code Online (Sandbox Code Playgroud)
序列化器看起来像这样:
class ServiceSerializer(serializers.ModelSerializer):
class Meta:
model = Service
fields = ('id', 'category_name', 'parent_id')
read_only_fields = ('category_name', 'parent_id')
Run Code Online (Sandbox Code Playgroud)
模型如下所示:
class Service(models.Model):
class …
Run Code Online (Sandbox Code Playgroud) 我已经定义了这样的路线:
$app->map(['GET', 'POST'],'/abc/[{url}]', function ($request, $response, $args) {
return $response;
})->add(new CustomMiddleware());
Run Code Online (Sandbox Code Playgroud)
当我传递一个 url 时它工作正常,http://
但给了我一个404 page not found
-Page with http://
or https://
。我也尝试过使用 url 编码的字符串,但给出了同样的错误:
$app->map(['GET', 'POST'],'/abc/[{url}]', function ($request, $response, $args) {
return $response;
})->add(new CustomMiddleware());
Run Code Online (Sandbox Code Playgroud)
我正在使用 Slim 3.1 版。
php ×3
arrays ×1
django ×1
firefox ×1
html ×1
javascript ×1
jquery ×1
jquery-knob ×1
localhost ×1
macos ×1
mamp ×1
php-5.3 ×1
php-5.4 ×1
python-2.7 ×1
react-hoc ×1
reactjs ×1
slim ×1
slim-3 ×1
ssl ×1
string ×1
typescript ×1
ubuntu ×1
virtualhost ×1