botEdukadu/syrenka/index.py

58 lines
2.6 KiB
Python
Raw Normal View History

2022-10-24 15:05:26 +02:00
#Sovnat GBF -
#Created by CubeSoftware
#-------------------------------
#Copyright (c) 2021-2022 CubeSoftware
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the #Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the #Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A #PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION #OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from flask import Flask, render_template
import requests
import json
import os
import apihelper
app = Flask(__name__)
PORT = int(os.environ.get('PORT', 4567))
@app.route("/")
@app.route("/index")
def index():
return render_template('home.htm', zurl1="/soon")
@app.route("/info")
def info():
return render_template('about.htm')
@app.route("/soon")
def soon():
return render_template('soon.htm')
@app.route("/tests")
def tests():
last = apihelper.get_last_6_tests()
test1 = last[0]
test2 = last[1]
test3 = last[1]
test4 = last[1]
return render_template('tests.htm', name1=test1["name"], subject1=test1["subject"], date1=test1["date"], topic1=test1["topic"], name2=test2["name"], subject2=test2["subject"], date2=test2["date"], topic2=test2["topic"]) #name3=test3["name"], subject3=test3["subject"], date3=test3["date"], topic3=test3["topic"], name4=test4["name"], subject4=test4["subject"], date4=test4["date"], topic4=test4["topic"])
@app.route("/new")
def new():
return render_template('public.htm')
@app.route('/quiz/<week>/')
def quiz(week):
return render_template('quiz.htm', answers=apihelper.get_all_quiz_answers_with_week_in_html(week), week=week)
@app.route('/newquiz/<week>/<name>/<subject>/<author>/<question>/<answer>/')
def newquiz(week, name, subject, author, question, answer):
apihelper.create_quiz_answer(name, author, subject, question, week, answer)
return render_template('public.htm')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=PORT, debug=True)