首页 > 解决方案 > 我在 GAE 上运行 python dash web 应用程序。它在本地运行良好,但是当我第一次尝试输入时,应用程序中的输入框没有反应?

问题描述

在标题的顶部,我实际上需要“输入”一些东西(没有出现)并按“开始”让应用程序开始做出反应。事实上,我终于可以输入并查看我的输入,并让程序按预期读取它。该应用程序目前已托管@ https://foodmoodai.appspot.com/ . username : test , passwd : test1,尽情享受吧!

我试图将输入框的初始状态从''更改' '为无济于事。我试图增加 CPU 资源,认为这是一个性能问题。

我的 app.yaml 文件:

runtime: python
env: flex
entrypoint: gunicorn app:app.server -b :$PORT

threadsafe: false

runtime_config:
  python_version: 2


resources:
  cpu: 1
  memory_gb: 1
  disk_size_gb: 10

Q(主文件)中代码的顶部:

import dash

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import plotly.graph_objs as go
from textwrap import dedent as d
from flask import Flask
import pandas as pd
import numpy as np
from NutrientParser import parseNutrientStr_frmUser,parseResearch,parseFoodResearch,find_substring
from userMindfuleClasses import *
#import time
#import dash_table as dtable
#import base64
import PIL  
import urllib3
from PIL import Image
import json,os
import arrow

from server import app

colors = {
    'logo_font' : '#797d7f',
    'logo_background' : ' #f2f3f4',
    'submit_button_font' : '#fbfcfc',
    'blue' : '#4530CA'                                              
}


layout = html.Div([

    #html.Img(className = 'company_logo',
        #src = '/.name_company_logo.jpg',
        #style={
                #'height' : '8%',
                #'width' : '8%',
                #'padding-top' : 15,
                #'padding-bottom' : 20,
                #'padding-left' : 10
            #}),
    html.Div(children = [  
            dcc.Input(
                id = 'meal_input',
                placeholder = 'Start typing...',
                value='', 
                style={
                    'textAlign': 'left',
                    'font-weight' : 'bold',
                    'color' : colors['logo_font'],
                    'background-color' : colors['logo_background'],
                    'position' : 'absolute',
                    'top' : '100px' ,
                    'left' : '315px',
                    'width' : '300px',
                    'height' : '30px',

                })
        ]), 

    html.Div(className = 'row_submit_button', children = [  
            html.Button(......

预期结果是我尝试的输入文本出现并影响应用程序中的其他组件,就像它在本地一样。实际上它只是停留在它的初始文本“开始输入......”并且根本没有反应。没有错误报告。

标签: python-3.xgoogle-app-enginegoogle-cloud-platform

解决方案


您在加载时发生了一些 JavaScipt 错误:

Uncaught (in promise) TypeError: undefined does not have a method named "concat"
    at bundle.js?v=0.12.1:2
    at e (bundle.js?v=0.12.1:1)
    at bundle.js?v=0.12.1:1
    at Array.map (<anonymous>)
    at l (bundle.js?v=0.12.1:1)
    at bundle.js?v=0.12.1:2
    at Array.forEach (<anonymous>)
    at bundle.js?v=0.12.1:2

也许这就是为什么?


推荐阅读