角形前端未对Flask Application进行调用

时间:2019-01-28 06:02:10

标签: javascript angular rest

我在此网址http://127.0.0.1:5000/SectionA中运行了flask应用程序 我使用return jsonify(data)返回json格式的数据。当我从浏览器中访问URL时,它看起来像这样

enter image description here

我从这样的角度应用程序main-service.ts文件中调用此url

 public getVamData(id,section): Observable<any> {
         try {
         console.log("I am here getVAM");
         return this.http.get('http://localhost:5000/SectionA')
                .map((response: Response) => {
                    console.log("I am here getVAM2");
                    return response.json();
                }
            );
           }
        catch(e) {
        console.log('Error:', e);
        }   }

但是该URL没有访问flask应用程序。请让我知道我在想什么。

1 个答案:

答案 0 :(得分:1)

您必须订阅Observable,因为Observable是延迟加载的。 如果您在其他地方(例如组件)使用getVamData()服务方法,请在那里订阅。 这样使用

mycmd.Connection = myconnection.open

    mycmd.CommandText = "Insert into sales(item_code,item_name,quantity_sold,price,total) values('" & itemcodet.Text & "','" & itemnamet.Text & "','" & quantityt.Text & "','" & pricet.Text & "')"
    mycmd.ExecuteNonQuery()

    MsgBox("Data Added!!", MsgBoxStyle.Information, "Noticed..")

    'subtract from inventory

    mycmd.CommandText = "update inventory set total_quantity=total_quantity- '" & quantityt.Text & "'  where item_code='" & itemcodet.Text & "'"
    mycmd.ExecuteNonQuery()
    MsgBox("stocks decrease!!", MsgBoxStyle.Information, "Noticed..")
    myconnection.close()