-
Notifications
You must be signed in to change notification settings - Fork 32
/
app.py
41 lines (31 loc) · 932 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import threading
from flask import Flask, redirect, request, send_from_directory
from typing import cast
from views import views, challenge
from views.sitemap import sitemapper
app = Flask(
__name__,
template_folder="templates",
static_folder="static",
static_url_path="/static",
)
app.register_blueprint(views.app_views)
sitemapper.init_app(app)
@app.errorhandler(404)
def page_not_found(err):
return redirect("/")
@app.route("/robots.txt")
def robots_txt():
return send_from_directory(cast(str, app.static_folder), request.path[1:])
@app.route("/sitemap.xml")
def r_sitemap():
return sitemapper.generate()
# Temporary solution for
# https://github.com/laike9m/Python-Type-Challenges/issues/49
threading.Thread(
target=challenge.challenge_manager.run_challenge,
kwargs={
"key": challenge.ChallengeKey(challenge.Level("basic"), "any"),
"user_code": "",
},
).start()