Enable dev and domain independent serving, add favicon
This commit is contained in:
		@ -1,7 +1,16 @@
 | 
			
		||||
from .app import app
 | 
			
		||||
from flask import send_from_directory
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
 | 
			
		||||
	@app.route('/')
 | 
			
		||||
	def get_root():
 | 
			
		||||
		return send_from_directory('../web', 'index.html')
 | 
			
		||||
 | 
			
		||||
	@app.route('/<path:path>')
 | 
			
		||||
	def get_path(path):
 | 
			
		||||
		return send_from_directory('../web', path)
 | 
			
		||||
 | 
			
		||||
	@app.after_request
 | 
			
		||||
	def add_headers(response):
 | 
			
		||||
		response.headers['Access-Control-Allow-Origin'] = '*'
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ def startup():
 | 
			
		||||
		pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@app.route('/<id>', methods = ['GET'])
 | 
			
		||||
@app.route('/db/<id>', methods = ['GET'])
 | 
			
		||||
def get(id):
 | 
			
		||||
	return data[id] if id in data else ('Error: Not found', 404)
 | 
			
		||||
 | 
			
		||||
@ -38,7 +38,7 @@ def generateNewKey():
 | 
			
		||||
 | 
			
		||||
	return id
 | 
			
		||||
 | 
			
		||||
@app.route('/', methods = ['POST'])
 | 
			
		||||
@app.route('/db', methods = ['POST'])
 | 
			
		||||
def post():
 | 
			
		||||
 | 
			
		||||
	id = generateNewKey()
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								web/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								web/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 4.1 KiB  | 
@ -31,7 +31,7 @@ function changeView(view) {
 | 
			
		||||
 | 
			
		||||
function showLink() {
 | 
			
		||||
 | 
			
		||||
	var link = 'https://quiz.fasttube.de/?id=' + state.id
 | 
			
		||||
	var link = location.href + '?id=' + state.id
 | 
			
		||||
 | 
			
		||||
	var linkEl = document.getElementById('shareLink')
 | 
			
		||||
	linkEl.href = link
 | 
			
		||||
@ -71,7 +71,7 @@ async function shareQuiz() {
 | 
			
		||||
	console.log(quizData)
 | 
			
		||||
	console.log('Waiting for id')
 | 
			
		||||
 | 
			
		||||
	var db = 'https://quiz.fasttube.de/db/'
 | 
			
		||||
	var db = location.href + 'db'
 | 
			
		||||
 | 
			
		||||
	var response = await fetch(db, {
 | 
			
		||||
		method: 'POST',
 | 
			
		||||
@ -486,7 +486,7 @@ async function fetchQuiz(id) {
 | 
			
		||||
 | 
			
		||||
	console.log('Fetching quiz')
 | 
			
		||||
 | 
			
		||||
	var url = 'https://quiz.fasttube.de/db/' + id
 | 
			
		||||
	var url = location.href + 'db/' + id
 | 
			
		||||
 | 
			
		||||
	var response = await fetch(url)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user