小编Mat*_*son的帖子

更改从ID到用户名的设计路线

我已尝试使用帖子更改路由以指向用户名.我知道这很简单,但由于某种原因我目前无法计算它.我也在设计文档页面上尝试了所有内容.

绘制用户名路由

我只想让路由布局使用用户名而不是id而不是用户前缀.喜欢:

http://example.com/username

代替

http://example.com/users/1

devise ruby-on-rails-3

8
推荐指数
1
解决办法
2828
查看次数

无法使用django social auth动态重定向到上次访问过的页面

在特定活动页面上.用户可以使用django social auth登录,但会将它们重定向到静态URL,并使用下面的选项

SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/dashboard/'
Run Code Online (Sandbox Code Playgroud)

我想知道是否有一种动态的方式重定向到他们登录的页面.我试过这个,但它没有用.

{% url socialauth_begin 'facebook' %}?redirect_uri={{ request.get_full_path }}
Run Code Online (Sandbox Code Playgroud)

任何建议都会非常感谢.

马修

django django-socialauth

6
推荐指数
1
解决办法
1317
查看次数

如何使用 Solidity 和 Web.js 在以太坊区块链上保存和检索数据

下面的代码仅返回收据,但我希望它返回一个数据元组,如下面的合同所示。我如何让它返回数据?我找不到关于如何保存和检索数据的好教程。我知道这是一个昂贵的用例,我只是想做一个基本的概念证明并同时学习。

我正在使用 web3@1.0.0-beta.29

export class AppComponent {
  title = 'app';
  dappUrl: string = 'http://myapp.com';
  web3: any;
  contractHash: string = '0x3b8a60616bde6f6d251e807695900f31ab12ce1a';
  MyContract: any;
  contract: any;
  ABI: any = [{"constant":true,"inputs":[{"name":"idx","type":"uint256"}],"name":"getLocationHistory","outputs":[{"name":"delegate","type":"address"},{"name":"longitude","type":"uint128"},{"name":"latitude","type":"uint128"},{"name":"name","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"recentLocation","outputs":[{"name":"delegate","type":"address"},{"name":"longitude","type":"uint128"},{"name":"latitude","type":"uint128"},{"name":"name","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"longitude","type":"uint128"},{"name":"latitude","type":"uint128"},{"name":"name","type":"bytes32"}],"name":"saveLocation","outputs":[],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"getLastLocation","outputs":[{"components":[{"name":"delegate","type":"address"},{"name":"longitude","type":"uint128"},{"name":"latitude","type":"uint128"},{"name":"name","type":"bytes32"}],"name":"recentLocation","type":"tuple"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"locations","outputs":[{"name":"delegate","type":"address"},{"name":"longitude","type":"uint128"},{"name":"latitude","type":"uint128"},{"name":"name","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"item","outputs":[{"name":"id","type":"bytes32"},{"name":"name","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"id","type":"bytes32"},{"name":"name","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}];


  constructor(private route: ActivatedRoute) { }

  @HostListener('window:load')
  windowLoaded() {
    this.checkAndInstantiateWeb3();
    this.getLocation();
  }

  getLocationHistory() {
    this.MyContract.methods
      .getLocationHistory(0).send({
      'from': '0x902D578B7E7866FaE71b3AB0354C9606631bCe03',
      'gas': '44000'
    }).then((result) => {
      this.MyContract.methods.getLocationHistory(0).call()
        .then(hello => {console.log('hello', hello)});
    });
  }

  private checkAndInstantiateWeb3 = () => {
    if (typeof window.web3 !== 'undefined') {
      console.warn('Using web3 detected from external source.');
      // Use Mist/MetaMask's provider
      this.web3 …
Run Code Online (Sandbox Code Playgroud)

ethereum solidity web3js

6
推荐指数
1
解决办法
5077
查看次数

Google计算负载均衡器会在DELETE上引发400 Bad Request

我通过实例模板创建了一个实例组,并将此实例组与http负载均衡器使用的后端服务对齐.

现在,当我打开一个URL从我创建实例组的实例虚拟机,我可以做GET POST,并DELETE请求和所有的请求的速度快,一切都按预期工作.

当我打开负载均衡器的静态IP的URL时.我可以做GETPOST请求,但DELETE请求抛出400 BAD REQUEST一个响应页面说:

那是一个错误.

您的客户发出了格式错误或非法的请求.我们知道的就这些.

其他负载均衡器问题:

  • 通过负载均衡器,站点速度很慢.也许有一个我缺少的设置,我很确定我把所有东西都设置为我们 - 中心-1b.
  • 有时网站甚至没有出现.它适用于http,但它不适用于https,反之亦然.负载均衡器具有非常奇怪的行为.

我的VM api访问权限设置为此实例具有对所有Google Cloud服务的完全API访问权限

我正在使用Django作为我的api层,我打开了这个主机上的调试,发现在DELETE通过loadbalancer static ip发出请求时,请求甚至没有通过.我缺少防火墙设置吗?

请帮助我再次快速执行此操作并允许DELETE请求发生.

谢谢!

load-balancing google-compute-engine google-cloud-platform

3
推荐指数
1
解决办法
1015
查看次数