Skip to content

Commit

Permalink
Flask templates - log files
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsPL committed Nov 25, 2018
1 parent cf04de5 commit 53b0250
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
2 changes: 1 addition & 1 deletion autowx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
t1 = Thread(target = mainLoop)
t1.setDaemon(True)
t1.start()
app.run(debug=True)
app.run(debug=True, port=webInterfacePort)
43 changes: 39 additions & 4 deletions autowx2_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,51 @@

# configuration
from autowx2_conf import *

from autowx2_functions import * # all functions and magic hidden here
from flask import Flask, render_template
import codecs

# satellites = list(satellitesData)
# qth = (stationLat, stationLon, stationAlt)

app = Flask(__name__, template_folder="var/flask/templates/", static_folder='var/flask/static') # " template_folder="var/flask/templates/"
def file_read(filename):
with codecs.open(filename, 'r', encoding='utf-8') as f:
lines = f.read()
return lines


# -------------------------------------------------------------------------- #


app = Flask(__name__, template_folder="var/flask/templates/", static_folder='var/flask/static')

body="hello!"
body="body"

#
# homepage
#

@app.route('/')
def homepage():
return render_template('index.html', body=body)
return render_template('index.html', title="Home page", body=body)


#
# display last log
#

@app.route('/lastlog')
def lastlog():
logfile = logFile(loggingDir)
logs = file_read(logfile)
body = "<p><strong>File</strong>: %s</p><pre class='small'>%s</pre>" % (logfile, logs)
return render_template('index.html', title="Recent logs", body=body)

#
# show pass table
#

@app.route('/table')
def passTable():
body=file_read(htmlNextPassList)
return render_template('index.html', title="Pass table", body=body)
19 changes: 12 additions & 7 deletions var/flask/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="description" content="autowx2 atomated satellite receiving station">
<meta name="author" content="filipsPL@github">

<title>autowx2 atomated satellite receiving station :: $htmlTitle</title>
<title>autowx2 atomated satellite receiving station :: {{title}}}}</title>

<!-- Bootstrap core CSS -->
<link href="{{ url_for('static',filename='bootstrap.min.css') }}" rel="stylesheet">
Expand All @@ -35,13 +35,15 @@
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Home
<span class="sr-only">(current)</span>
</a>
<a class="nav-link" href="/">Home<span class="sr-only">(current)</span></a>
</li>
<a class="nav-link" href="/table.html">Pass table
</a>
<li>
<a class="nav-link" href="/table">Pass table</a>
</li>
<li>
<a class="nav-link" href="/lastlog">Recent logs</a>
</li>

<li class="nav-item">
<a class="nav-link" href="https://github.com/filipsPL/autowx2">Source code</a>
</li>
Expand All @@ -52,8 +54,11 @@

<!-- Page Content -->
<div class="container">

<h1>{{title}}</h1>
{% autoescape false %}
{{ body }}
{% endautoescape %}

</div>
<!-- /.container -->

Expand Down

0 comments on commit 53b0250

Please sign in to comment.