Initial commit
This commit is contained in:
32
main.py
Normal file
32
main.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from flask import Flask, redirect, url_for, request, render_template, jsonify
|
||||
from collections import deque
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return render_template("index.html")
|
||||
|
||||
@app.route('/input')
|
||||
def show():
|
||||
return render_template("input.html")
|
||||
|
||||
@app.route("/get_phrases")
|
||||
def getPhrases():
|
||||
with open("frasi.txt", "r") as file:
|
||||
lastLines = deque(file, 5)
|
||||
return jsonify(list(lastLines))
|
||||
|
||||
@app.route('/input', methods=['POST', 'GET'])
|
||||
def login():
|
||||
if request.method == 'POST':
|
||||
phrase = request.form['nm']
|
||||
with open("frasi.txt", "a") as file:
|
||||
file.write(phrase + "\n")
|
||||
return render_template("index.html")
|
||||
else:
|
||||
return render_template("index.html")
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
|
||||
Reference in New Issue
Block a user