2016-08-11 2 views
-1

私はここにこだわりました 私はBanana Piボードでプロジェクトを行い、Debian関連のOSをインストールしています Python 2.7を使用しています。私のプロジェクトで私のテンプレートにIframeを使用しています

  • main.htmlを
  • motor1.html
  • motor2.html
  • sensor1.html
  • sensor2.html

: 私は、彼らが4つのhtmlページを持っていました

Flaskアプリケーションを使用してmain.htmlを実行しています。このmain.htmlには他のすべてのページが含まれています

<!DOCTYPE html> 
    <html> 
    <head> 
    <title>Pi Board</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
    <script> 
    function myFunc(){ 
     setTimeout("location.reload(true);",60000); 
    } 
    myFunc(); 
    </script> 
    <style> 
    body {background-color : lightgray;} 
    #frame1,#frame2{width: 300px; height : 200px; float: absolute;} 

    </style> 
    </head> 
    <body > 
    <header><h2>XYZ Automation</h2></header> 
    <iframe id="frame1" src="motor1.html"></iframe> 
    <iframe id="frame1" src="sensor1.html"></iframe><br> 
    <iframe id="frame2" src="motor2.html"></iframe> 
    <iframe id="frame2" src="sensor2.html"></iframe> 
    </body> 
    </html> 

と、次のように私は、フォルダ内のすべてのファイルを保持: プロジェクトapp.pyためmain.htmlを内のiframeの

私のコードは

from flask import Flask,render_template 
    app = Flask(__name__) 

    @app.route('/') 
    def index(): 
    return render_template('main.html')  
    if __name__ == "__main__": 
     app.run(debug=True)  

次のようにmain.htmlとがあります(MainFolder): - > テンプレート テンプレート(サブフォルダ): main.html 、motor1.html 、motor2.h tml 、sensor1.html 、sensor2.html 、script.js。 、スタイル(フォルダ) スタイル(フォルダ): - : in commandline in browser

PS:> Styles.cssを、ここで

は、私は、コードを実行していながら、イメージがある私はフラスコで作業を開始しました初めて、私はこれらのサーバの事には知識がありませんでした。これは私の先生から与えられたプロジェクトです。私を助けてください。

ありがとう、

クリシュナ。あなたはページのapp.routeエントリを作成する必要が

+0

「app.py」にインデントを修正してください –

答えて

0

は、このようなapp.pyファイル内SENSOR1とセンサ2、モータ2をモータ1:main.htmlとで

@app.route('motor1') 
def motor1(): 
    return render_template('motor1.html') 

@app.route('motor2') 
def motor2(): 
    return render_template('motor2.html') 

@app.route('sensor1') 
def sensor1(): 
    return render_template('sensor1.html') 

@app.route('sensor2') 
def sensor2(): 
    return render_template('sensor2.html') 

インラインフレームソースが.htmlの終末を必要としません:

<iframe id="frame1" src="motor1"></iframe> 
<iframe id="frame2" src="sensor1"></iframe> 
<iframe id="frame3" src="motor2"></iframe> 
<iframe id="frame4" src="sensor2"></iframe> 
関連する問題