forked from starnakin/ca42
core: use date
This commit is contained in:
parent
7890be2ed2
commit
0f02669f5c
23
main.py
23
main.py
@ -1,5 +1,5 @@
|
||||
from flask import Flask, render_template, request, redirect, session
|
||||
import time
|
||||
from flask import Flask, render_template, redirect
|
||||
import datetime
|
||||
|
||||
app = Flask(__name__);
|
||||
|
||||
@ -10,18 +10,21 @@ try:
|
||||
last_value: str = f.read()
|
||||
except:
|
||||
with open("bozo", 'w+') as f:
|
||||
last_value = str(time.time() * 1000)
|
||||
last_value = str(datetime.date.today())
|
||||
f.write(last_value)
|
||||
|
||||
@app.route("/api/update", methods = ['GET'])
|
||||
def get():
|
||||
return str(last_value)
|
||||
|
||||
@app.route("/api/update", methods = ['POST'])
|
||||
def update():
|
||||
last_value = str(time.time() * 1000)
|
||||
f.write(last_value)
|
||||
return
|
||||
last_value = str(datetime.date.today())
|
||||
print(last_value)
|
||||
with open("bozo", 'w+') as f:
|
||||
f.write(last_value)
|
||||
return render_template('home.html', date = last_value)
|
||||
|
||||
@app.route("/", methods = ['GET'])
|
||||
def normal():
|
||||
print(last_value)
|
||||
return render_template('home.html', date = last_value)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000, debug=1)
|
||||
|
14
templates/home.html
Normal file
14
templates/home.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ca42</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Ca42</h1>
|
||||
<h1>{{date}}</h1>
|
||||
<form action="/api/update" method="post">
|
||||
<button name="foo" value="upvote">Upvote</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user