标签: backend

python 代码后端和 flutter 之间的链接

我正在考虑将用 python 编写的后端代码链接到移动应用程序,我想在 flutter 上构建其前端;我尝试了 starflut 包并下载了示例代码,但它不起作用,不幸的是我不明白有关该库的 flutter 文档中写的内容。有人可以帮助我处理这个软件包,或者推荐更简单的方法来链接它们吗?

python frontend backend flutter

1
推荐指数
1
解决办法
2万
查看次数

如何保护后端不被其他未经授权的应用程序访问

如何保护我的后端不被其他未经授权的前端应用程序访问?我用谷歌搜索,找不到提供完整解决方案的解决方案。Instagram、Facebook 等公司如何阻止未经授权的请求?我读到 SSL 密钥可以通过对前端进行逆向工程找到。我是一个菜鸟,正在为一个项目构建一个社交网络。请指导我。

security authentication frontend backend

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

错误:keras.backend 没有属性“set_image_dim_ordering”

当尝试做的时候set_image_dim_ordering('th')

from keras import backend as K

K.set_image_dim_ordering('th')
Run Code Online (Sandbox Code Playgroud)

我遇到属性错误:

AttributeError: module 'keras.backend' has no attribute 'set_image_dim_ordering'
Run Code Online (Sandbox Code Playgroud)

python backend conv-neural-network keras

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

nodeJS 与 Google API 异步等待

我正在使用 Google Calendar API,它按预期工作。但我对里面的异步方法有疑问。

因此,我有以下请求路线来获取来自特定用户的所有事件:

router.get('/api/user/calendar/listEvents', async (req, res) => {
  try {

    const token = "123456789"

      var oAuth = authorizationHelper(token)

         var events = await listEvents(oAuth, req.body.date)

    res.status(200).send(events)
  } catch (e) {
    res.status(400).send("Error Bad Request")
    console.log(e)
  }
})
Run Code Online (Sandbox Code Playgroud)

我的 listEvents 方法:

   async function listEvents(auth, date) {
  var events;
  const calendar = google.calendar({ version: 'v3', auth });
   const eventsA = calendar.events.list({
    calendarId: 'primary',
    timeMin: date,
    maxResults: 1,
    singleEvents: true,
    orderBy: 'startTime',
  }, (err, res) => {
    if (err) return console.log('The API …
Run Code Online (Sandbox Code Playgroud)

backend google-calendar-api google-api node.js server

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

如何访问 Django 模板代码块中列表的长度?

在模板中,我有一个名为“参与者”的列表类型变量。例如,我想检查列表的长度是否等于 2。我尝试了以下方法:

{{ participants | json_script:"participants"}}

{% if participants|length==2 %}

.....
{% endif %}
Run Code Online (Sandbox Code Playgroud)

然而,这是行不通的。我得到的错误是:

/chat/lobby/ 处的 TemplateSyntaxError 无法解析其余部分:“participants.count==2”中的“==2”

有人可以指出一种在模板代码块中访问列表长度的方法吗?感谢您的时间和考虑!

python django backend web-development-server web

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

json.NewEncoder 和 json.NewDecoder 中的序列化/编码

我正在尝试通过使用 Go 中的 gorilla mux 库构建不同的基本 REST API 来学习后端开发(遵循本教程

这是我迄今为止构建的代码:

package main

import (
"encoding/json"
"net/http"

"github.com/gorilla/mux"
)

// Post represents single post by user
type Post struct {
Title  string `json:"title"`
Body   string `json:"body"`
Author User   `json:"author"`
}

// User is struct that represnets a user
type User struct {
FullName string `json:"fullName"`
Username string `json:"username"`
Email    string `json:"email"`
}

var posts []Post = []Post{}

func main() {
   router := mux.NewRouter()
   router.HandleFunc("/posts", addItem).Methods("POST")
   http.ListenAndServe(":5000", router)
}

func …
Run Code Online (Sandbox Code Playgroud)

rest json encode backend go

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

无法加载 WSGI 应用程序“mysite.wsgi.application”;导入模块时出错

我使用 django 3.1.1 和 Python 3.8.5。我想创建简单的博客。我使用一些旧代码,其中程序员可能使用 django 1.11,所以我改变了很多东西,但现在我陷入困境

我收到错误

    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'mysite.wsgi.application' could not be loaded; Error importing module.

Run Code Online (Sandbox Code Playgroud)

当我尝试删除时

WSGI_APPLICATION = 'mysite.wsgi.application'

Run Code Online (Sandbox Code Playgroud)

我收到一个错误

ImportError: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
Run Code Online (Sandbox Code Playgroud)

这是我的整个设置.py

"""
Django settings for mysite project.

Generated by 'django-admin startproject' using Django 1.8.6.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...) …
Run Code Online (Sandbox Code Playgroud)

python django backend django-settings python-3.x

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

如何使用 nginx proxy_pass api 路径到端口

我想将根位置 (/) 代理传递到端口 3000,将 /api 位置代理传递到端口 5000,这是完全可能的,对吗?

我的 nginx 配置文件:

server {
listen       80;
server_name  mywebsite.com;

location /api {
    proxy_pass http://localhost:5000;
}

location / {
    proxy_pass http://localhost:3000;
}
}
Run Code Online (Sandbox Code Playgroud)

如果我在本地执行 api 请求,我可以获得预期的输出:

myuser@myserver [conf.d]# curl localhost:5000
Hello, World!myuser@myserver [conf.d]#
Run Code Online (Sandbox Code Playgroud)

但对于 api 客户端则不然,从根路径到端口 3000 的 proxy_pass 在浏览器和 api 客户端中工作正常

笔记:

  • 我没有忘记重新加载 nginxsudo systemctl reload nginx
  • 防火墙允许两个端口中的流量,我正在使用ufw
  • 服务器操作系统是centos 7

port reverse-proxy http backend nginx

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

NextJs 重写产生 localhost redirected you too much times 错误

以下是我的next.config.js:

// next.config.js

module.exports = {
  async rewrites() {
    return [
      {
        source: '/results',
        destination: 'https://mywebsite.com/results',
      },
    ];
  },
};
Run Code Online (Sandbox Code Playgroud)

根据 Nextjs 重写文档(https://nextjs.org/docs/api-reference/next.config.js/rewrites#rewriting-to-an-external-url),访问 https://nextjswebsite.com/results,页面内容应使用https://mywebsite.com/results的内容重写。

然而,我最终得到“本地主机重定向你太多次”。

有什么想法导致错误吗?

javascript backend url-rewriting next.js

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

为什么我的 Mac 无法在端口 1000 上运行服务器?

我正在尝试使用 Express.js 运行服务器,每次尝试在端口 1000 上运行它时,我都会收到以下消息:

events.js:292
  throw er; // Unhandled 'error' event
  ^

Error: listen EACCES: permission denied 0.0.0.0:1000
at Server.setupListenHandle [as _listen2] (net.js:1301:21)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1452:7)
    at Function.listen (/Users/orensayag/Documents/johnBryce/26 - 210421/hw/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/Users/orensayag/Documents/johnBryce/26 - 210421/hw/index.js:6:5)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Run Code Online (Sandbox Code Playgroud)

在以下位置的服务器实例上发出“错误”事件:在 processTicksAndRejections (internal/process/task_queues.js:80:21) { code: 'EACCES', errno: -13,

  syscall: 'listen',
Run Code Online (Sandbox Code Playgroud)

地址:'0.0.0.0',端口:1000 }

我还听说 Mac 在此端口上运行时存在问题,而在 Windows 中它可以按预期运行。

为什么我的 Mac 无法在端口 1000 上运行服务器?

macos port backend express

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