小编Vin*_*tJr的帖子

使用Python Flask,AngularJS,测试/生产目录和服务请求

这是设置:

使用ngBoilerplate(grunt,bower,angular,works ......)来创建SAP应用程序.在我的localhost上,它启动了一个NodeJS服务器,以便我可以测试该应用程序.这一切都很好,减去数据库/ apis.使用Grunt,它将创建一个/ build文件夹(这是所有非缩小的源,资源,用于调试)和带有生产代码的/ bin文件夹.

对于后端,我在Heroku上有一个Python烧瓶应用程序(我将用于REST API).在主Python脚本中:

@app.route("/")
def index():
    #index.html has the angular SAP
    return make_response( open('build/index.html').read() )
Run Code Online (Sandbox Code Playgroud)

我将代码推送到Heroku,它检测到一个Python应用程序(我认为这很好,因为我需要Python来发出我的api请求),并且它提供了正确的index.html.我看到Angular向/vendor/angular.js /css/angular.css等发出请求,当这些文件技术上存在于/build/vendor/angular.js中时.

我不确定我是否想告诉Angular在哪里抓取文件或者它是否与Python相关.

我想在LAMP土地上改变DOCROOT(WWW)吗?我是否在Angular中更改routeprovider/urlrouterprovider以告诉它将文件提供给其他位置?或者我改变我在Python中所做的事情?

项目目录如下所示:

hellworld.py
requirements.txt
runp-heroku.py
procfile
Gruntfile.js
build/       //test code
  assets/
  index.html
  vendor/
bin/         //production code
  assets/
  index.html
  vendor/
src/         //original code
  assets/
  index.html
  vendor/
Run Code Online (Sandbox Code Playgroud)

python heroku flask angularjs

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

标签 统计

angularjs ×1

flask ×1

heroku ×1

python ×1