-
Notifications
You must be signed in to change notification settings - Fork 1
/
web.py
99 lines (76 loc) · 2.66 KB
/
web.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
from flask import Flask, session, request
import os.path #file exists
import random
import string
#custom modules
import lang
import configs
import dbhandler
#make context
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = configs.max_upload
#to suppress unicodedecodeerror
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
#session setup
app.secret_key = ''.join(random.choice(string.ascii_letters+string.digits) for _ in range(32))
@app.before_request
def guessLocale():
if not 'locale' in session or not session['locale']:
session['locale'] = request.accept_languages.best_match(['ko', 'en']) or 'ko'
import index
app.route('/')(index.index)
import signup
app.route('/signup')(signup.signup)
app.route('/signup/submit', methods=['POST'])(signup.signup_submit)
app.route('/confirm/resend')(signup.resend)
app.route('/confirm/<path:path>')(signup.confirm)
import login
app.route('/login')(login.login)
app.route('/login/submit', methods=['POST'])(login.login_submit)
app.route('/logout')(login.logout)
import static
app.route('/static/<path:path>')(static.static_files)
import robots
app.route('/robots.txt')(robots.robots)
app.route('/humans.txt')(robots.humans)
import error_handler
app.errorhandler(404)(error_handler.error_404)
app.errorhandler(500)(error_handler.error_500)
import stats
app.route('/stats')(stats.stats)
import probs
app.route('/probs')(probs.probs)
app.route('/probs/<int:page>')(probs.probs)
import user
app.route('/user')(user.user)
app.route('/changeuser')(user.changeuser)
app.route('/changeuser/submit', methods=['POST'])(user.changeuser_submit)
app.route('/findacc')(user.findacc)
#app.route('/findacc/submit', methods=['POST'])(user.findacc_submit)
import viewprob
app.route('/viewprob/<probid>')(viewprob.viewprob)
app.route('/settheme/<theme>')(viewprob.settheme)
import submit
app.route('/submit/<probid>', methods=['POST'])(submit.submit)
import addprob
app.route('/addprob')(addprob.addprob)
app.route('/addprob/submit', methods=['POST'])(addprob.addprob_submit)
import changelang
app.route('/changelang/<lang>')(changelang.changelang)
import upload
app.route('/upload')(upload.upload)
app.route('/upload/submit', methods=['POST'])(upload.submitfile)
app.route('/uploads/<filename>')(upload.userfile)
import editprob
app.route('/editprob/<probid>')(editprob.editprob)
app.route('/editprob/<probid>/submit',methods=['POST'])(editprob.editprob_submit)
import contests
app.route('/contests')(contests.contests)
import addcontest
app.route('/addcontest')(addcontest.addcontest)
app.route('/addcontest/submit',methods=['POST'])(addcontest.addcontest_submit)
if __name__ == '__main__':
app.run(debug=configs.debugMode, port=5000)