使用Wordnik将python 3.4 app部署到bluemix

时间:2015-04-16 12:50:41

标签: python python-3.4 cloudfoundry ibm-cloud

我在使用Bluemix启动并运行我的Python 3.4.1应用程序时遇到问题。这是我的应用程序。

当我的应用程序尝试在Bluemix中启动时,它永远不会启动,它最终会说下来。有什么想法吗?

manifest.yml:

    ---
    applications:
    - name: myappname
      buildpack: python_buildpack
      instances: 1
      memory: 128M

Procfile:

web: python server.py

requirements.txt:

Flask==0.10.1

server.py:

"""Cloud Foundry test"""
from flask import Flask,request,render_template
import os

##########API DOESN"T WORK WHEN DEPLOYING TO BLUEMIX#######
from wordnik import *
apiUrl = 'http://api.wordnik.com/v4'
apiKey = 'myapikey'
client = swagger.ApiClient(apiKey, apiUrl)
 ##Call api to be used in WordApi
wordApi = WordApi.WordApi(client)


app = Flask(__name__)

if os.getenv("VCAP_APP_PORT"):
    port = int(os.getenv("VCAP_APP_PORT"))
else:
    port = 8080

@app.route('/')
def index():
    return render_template("firstForm.html")



@app.route("/main", methods=["POST"])

def ouch():
    return "Hello... World?"




if __name__ == '__main__':
    app.run(host='0.0.0.0', port=port)

1 个答案:

答案 0 :(得分:2)

我通过将wordnik添加到我的requirements.txt文件中解决了这个问题。在Windows(我的本地计算机)上安装了依赖项,但在Bluemix中却没有。我需要在requirements.txt文件中明确调出每个依赖项:

Flask==0.10.1
wordnik-py3