私は実際に問題を解決しました。私は(煙と鏡の略)「煙」という名前のディレクトリを持っており、内部が、私は、角-CLIコマンドを実行しました:
ng new static
これは、静的なディレクトリにアプリケーションを起動し、角度-CLIを作成しました。私はhttp://localhost:5000に移動することができ、アプリケーションが単にない「NGサーブ」のような角度アプリを果たすだろう
import os
from flask import Flask, send_from_directory, redirect
from flask.ext.restful import Api
from gevent import monkey, pywsgi
monkey.patch_all()
def create_app():
app = Flask("press_controller")
# map the root folder to index.html
@app.route("/")
def home():
return redirect("/index.html")
@app.route("/<path:path>")
def root(path):
"""
This is the cheesy way I figured out to serve the Angular2 app created
by the angular-cli system. It essentially serves everything from
static/dist (the distribution directory created by angular-cli)
"""
return send_from_directory(os.path.join(os.getcwd(), "static/dist"), path)
return app
if __name__ == "__main__":
app = create_app()
server = pywsgi.WSGIServer(("0.0.0.0", 5000), app)
server.serve_forever()
else:
app = create_app()
この方法:それから私は、この(簡体字)のPythonフラスコアプリケーションを作成しました。これでREST APIエンドポイントを追加して、必要に応じてAngularサービスにアクセスさせて、アプリケーションにデータを入れることができます。
ダグ
ご意見ありがとうございます。私は前進するためにその道を進む必要があるかもしれません。私を悩ます内部的な理由から、Flaskアプリケーションは、nginxのようなものを提供するのではなく、独自の静的ファイルを提供します。私はこれが愚かだと知っていますが、私のコントロールではありません。しかし、私のFlaskアプリケーションが静的ファイルを提供していることを考えると、Angular Cliで作成された新しいアプリケーション名フレームワークは新しいサービス名で機能しますが、Flaskで静的ファイルを提供しようとすると失敗します。 main.jsファイルはロードされているとはいえ、実行されていないようです。 –
@writes_onもしあなたが特定の問題を抱えているなら、それを示す[mcve]を作成する必要があります。 – davidism