Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Weather_Station/WeatherOld.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
57 lines (43 sloc)
1.01 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from w1thermsensor import W1ThermSensor | |
from flask import Flask | |
from flask import render_template | |
import socket | |
app = Flask(__name__) | |
def Temperature(): | |
sensor = W1ThermSensor() | |
temperature = sensor.get_temperature() | |
return temperature | |
def WebpageSet(temp): | |
W = open("\Templates\index.html", "w") | |
F = open("First.txt", "r") | |
L = open("Last.txt", "r") | |
W.write(F.read() + str(temp) + L.read()) | |
print("TEST") | |
F.close() | |
L.close() | |
W.close() | |
temp = 25 | |
W = open("Templates\index.html", "w") | |
F = open("First.txt", "r") | |
L = open("Last.txt", "r") | |
W.write(F.read() + str(temp) + L.read()) | |
print("TEST") | |
F.close() | |
L.close() | |
W.close() | |
def get_ip_address(): | |
ip_address = ''; | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
s.connect(("8.8.8.8",80)) | |
ip_address = s.getsockname()[0] | |
s.close() | |
return ip_address | |
@app.route("/") | |
def index(): | |
WebpageSet(25) | |
return render_template('index.html') | |
if __name__ == '__main__': | |
#app.run(threaded=True) | |
#app.debug = True | |
app.run(host = get_ip_address()) | |