app.py 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. # Init
  2. import os
  3. import re
  4. import signal
  5. import atexit
  6. import logging
  7. from route.tool.func import *
  8. from route import *
  9. args = sys.argv
  10. run_mode = ''
  11. if len(args) > 1:
  12. run_mode = args[1]
  13. if not run_mode in ('dev'):
  14. run_mode = ''
  15. # Init-Version
  16. with open('version.json', encoding = 'utf8') as file_data:
  17. version_list = orjson.loads(file_data.read())
  18. # Init-DB
  19. data_db_set = class_check_json()
  20. do_db_set(data_db_set)
  21. with class_temp_db() as m_conn:
  22. m_conn.execute('pragma journal_mode = WAL')
  23. with get_db_connect(init_mode = True) as conn:
  24. curs = conn.cursor()
  25. setup_tool = ''
  26. try:
  27. curs.execute(db_change('select data from other where name = "ver"'))
  28. except:
  29. setup_tool = 'init'
  30. if setup_tool != 'init':
  31. ver_set_data = curs.fetchall()
  32. if ver_set_data:
  33. if int(version_list['c_ver']) > int(ver_set_data[0][0]):
  34. setup_tool = 'update'
  35. else:
  36. setup_tool = 'normal'
  37. else:
  38. setup_tool = 'init'
  39. if setup_tool != 'normal' and run_mode != 'dev':
  40. file_name = linux_exe_chmod()
  41. local_file_path = os.path.join("route_go", "bin", file_name)
  42. if os.path.exists(local_file_path):
  43. print('Remove Old Binary')
  44. os.remove(local_file_path)
  45. download_url = version_list["bin_link"] + file_name
  46. print('Download New Binary File')
  47. response = requests.get(download_url, stream = True)
  48. if response.status_code == 200:
  49. with open(local_file_path, 'wb') as file:
  50. for chunk in response.iter_content(chunk_size = 8192):
  51. file.write(chunk)
  52. print('Complete Download')
  53. if data_db_set['type'] == 'mysql':
  54. try:
  55. curs.execute(db_change('create database ' + data_db_set['name'] + ' default character set utf8mb4'))
  56. except:
  57. try:
  58. curs.execute(db_change('alter database ' + data_db_set['name'] + ' character set utf8mb4'))
  59. except:
  60. pass
  61. conn.select_db(data_db_set['name'])
  62. else:
  63. conn.execute('pragma journal_mode = WAL')
  64. if setup_tool != 'normal':
  65. create_data = get_db_table_list()
  66. for create_table in create_data:
  67. for create in ['test'] + create_data[create_table]:
  68. db_pass = 0
  69. try:
  70. curs.execute(db_change('select ' + create + ' from ' + create_table + ' limit 1'))
  71. db_pass = 1
  72. except:
  73. pass
  74. field_text = 'longtext' if data_db_set['type'] == 'mysql' else 'text'
  75. if db_pass == 0:
  76. try:
  77. curs.execute(db_change('create table ' + create_table + '(test ' + field_text + ' default (""))'))
  78. db_pass = 1
  79. except Exception as e:
  80. # print(e)
  81. pass
  82. if db_pass == 0:
  83. try:
  84. curs.execute(db_change('create table ' + create_table + '(test ' + field_text + ' default "")'))
  85. db_pass = 1
  86. except Exception as e:
  87. # print(e)
  88. pass
  89. if db_pass == 0:
  90. try:
  91. curs.execute(db_change('create table ' + create_table + '(test ' + field_text + ')'))
  92. db_pass = 1
  93. except Exception as e:
  94. # print(e)
  95. pass
  96. if db_pass == 0:
  97. try:
  98. curs.execute(db_change("alter table " + create_table + " add column " + create + " " + field_text + " default ('')"))
  99. db_pass = 1
  100. except Exception as e:
  101. # print(e)
  102. pass
  103. if db_pass == 0:
  104. try:
  105. curs.execute(db_change("alter table " + create_table + " add column " + create + " " + field_text + " default ''"))
  106. db_pass = 1
  107. except Exception as e:
  108. # print(e)
  109. pass
  110. if db_pass == 0:
  111. try:
  112. curs.execute(db_change("alter table " + create_table + " add column " + create + " " + field_text))
  113. db_pass = 1
  114. except Exception as e:
  115. # print(e)
  116. pass
  117. if db_pass == 0:
  118. raise
  119. try:
  120. curs.execute(db_change("create index history_index on history (title, ip)"))
  121. except:
  122. pass
  123. if setup_tool == 'update':
  124. update(conn, int(ver_set_data[0][0]), data_db_set)
  125. else:
  126. set_init(conn)
  127. set_init_always(conn, version_list['c_ver'], run_mode)
  128. # Init-Route
  129. class EverythingConverter(werkzeug.routing.PathConverter):
  130. def __init__(self, map):
  131. super(EverythingConverter, self).__init__(map)
  132. self.regex = r'.*?'
  133. def to_python(self, value):
  134. return re.sub(r'^\\\.', '.', value)
  135. class RegexConverter(werkzeug.routing.BaseConverter):
  136. def __init__(self, url_map, *items):
  137. super(RegexConverter, self).__init__(url_map)
  138. self.regex = items[0]
  139. app = flask.Flask(__name__, template_folder = './')
  140. app.config['JSON_AS_ASCII'] = False
  141. app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
  142. app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3600
  143. if run_mode == 'dev':
  144. app.config['TEMPLATES_AUTO_RELOAD'] = True
  145. app.config['DEBUG'] = True
  146. app.config['ENV'] = 'development'
  147. log = logging.getLogger('waitress')
  148. log.setLevel(logging.ERROR)
  149. app.jinja_env.filters['md5_replace'] = md5_replace
  150. app.jinja_env.filters['load_lang'] = load_lang
  151. app.jinja_env.filters['cut_100'] = cut_100
  152. app.url_map.converters['everything'] = EverythingConverter
  153. app.url_map.converters['regex'] = RegexConverter
  154. curs.execute(db_change('select data from other where name = "key"'))
  155. sql_data = curs.fetchall()
  156. app.secret_key = sql_data[0][0]
  157. # Init-DB_Data
  158. server_set = {}
  159. server_set_var = get_init_set_list()
  160. server_set_env = {
  161. 'host' : os.getenv('NAMU_HOST'),
  162. 'golang_port' : os.getenv('NAMU_GOLANGPORT'),
  163. 'port' : os.getenv('NAMU_PORT'),
  164. 'language' : os.getenv('NAMU_LANG'),
  165. 'markup' : os.getenv('NAMU_MARKUP'),
  166. 'encode' : os.getenv('NAMU_ENCRYPT')
  167. }
  168. for i in server_set_var:
  169. curs.execute(db_change('select data from other where name = ?'), [i])
  170. server_set_val = curs.fetchall()
  171. if server_set_val:
  172. server_set_val = server_set_val[0][0]
  173. elif server_set_env[i] != None:
  174. server_set_val = server_set_env[i]
  175. curs.execute(db_change('insert into other (name, data, coverage) values (?, ?, "")'), [i, server_set_env[i]])
  176. else:
  177. if 'list' in server_set_var[i]:
  178. print(server_set_var[i]['display'] + ' (' + server_set_var[i]['default'] + ') [' + ', '.join(server_set_var[i]['list']) + ']' + ' : ', end = '')
  179. else:
  180. print(server_set_var[i]['display'] + ' (' + server_set_var[i]['default'] + ') : ', end = '')
  181. server_set_val = input()
  182. if server_set_val == '':
  183. server_set_val = server_set_var[i]['default']
  184. elif server_set_var[i]['require'] == 'select':
  185. if not server_set_val in server_set_var[i]['list']:
  186. server_set_val = server_set_var[i]['default']
  187. curs.execute(db_change('insert into other (name, data, coverage) values (?, ?, "")'), [i, server_set_val])
  188. print(server_set_var[i]['display'] + ' : ' + server_set_val)
  189. server_set[i] = server_set_val
  190. with class_temp_db() as m_conn:
  191. m_curs = m_conn.cursor()
  192. for for_a in server_set:
  193. m_curs.execute('insert into temp (name, data) values (?, ?)', ['setup_' + for_a, server_set[for_a]])
  194. ###
  195. if platform.system() == 'Linux':
  196. if platform.machine() in ["AMD64", "x86_64"]:
  197. cmd = [os.path.join(".", "route_go", "bin", "main.amd64.bin")]
  198. else:
  199. cmd = [os.path.join(".", "route_go", "bin", "main.arm64.bin")]
  200. elif platform.system() == 'Darwin':
  201. cmd = [os.path.join(".", "route_go", "bin", "main.mac.arm64.bin")]
  202. else:
  203. if platform.machine() in ["AMD64", "x86_64"]:
  204. cmd = [os.path.join(".", "route_go", "bin", "main.amd64.exe")]
  205. else:
  206. cmd = [os.path.join(".", "route_go", "bin", "main.arm64.exe")]
  207. if run_mode != '':
  208. cmd += [run_mode]
  209. def golang_process_check():
  210. with class_temp_db() as m_conn:
  211. m_curs = m_conn.cursor()
  212. m_curs.execute('select data from temp where name = "setup_golang_port"')
  213. db_data = m_curs.fetchall()
  214. db_data = db_data[0][0] if db_data else "3001"
  215. while True:
  216. try:
  217. response = requests.post('http://localhost:' + db_data + '/', data = "test {}")
  218. if response.status_code == 200:
  219. print('Golang turn on')
  220. break
  221. except requests.ConnectionError:
  222. print('Wait golang...')
  223. time.sleep(1)
  224. golang_process = subprocess.Popen(cmd)
  225. golang_process_check()
  226. ###
  227. def back_up(data_db_set):
  228. with get_db_connect() as conn:
  229. curs = conn.cursor()
  230. try:
  231. curs.execute(db_change('select data from other where name = "back_up"'))
  232. back_time = curs.fetchall()
  233. back_time = float(number_check(back_time[0][0], True)) if back_time and back_time[0][0] != '' else 0
  234. curs.execute(db_change('select data from other where name = "backup_count"'))
  235. back_up_count = curs.fetchall()
  236. back_up_count = int(number_check(back_up_count[0][0])) if back_up_count and back_up_count[0][0] != '' else 3
  237. if back_time != 0:
  238. curs.execute(db_change('select data from other where name = "backup_where"'))
  239. back_up_where = curs.fetchall()
  240. back_up_where = back_up_where[0][0] if back_up_where and back_up_where[0][0] != '' else data_db_set['name'] + '.db'
  241. print('Back up state : ' + str(back_time) + ' hours')
  242. print('Back up directory : ' + back_up_where)
  243. if back_up_count != 0:
  244. print('Back up max number : ' + str(back_up_count))
  245. file_dir = os.path.split(back_up_where)[0]
  246. file_dir = '.' if file_dir == '' else file_dir
  247. file_name = os.path.split(back_up_where)[1]
  248. file_name = re.sub(r'\.db$', '_[0-9]{14}.db', file_name)
  249. backup_file = [for_a for for_a in os.listdir(file_dir) if re.search('^' + file_name + '$', for_a)]
  250. backup_file = sorted(backup_file)
  251. if len(backup_file) >= back_up_count:
  252. remove_dir = os.path.join(file_dir, backup_file[0])
  253. os.remove(remove_dir)
  254. print('Back up : Remove (' + remove_dir + ')')
  255. now_time = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
  256. new_file_name = re.sub(r'\.db$', '_' + now_time + '.db', back_up_where)
  257. shutil.copyfile(
  258. data_db_set['name'] + '.db',
  259. new_file_name
  260. )
  261. print('Back up : OK (' + new_file_name + ')')
  262. else:
  263. print('Back up state : Turn off')
  264. back_time = 1
  265. except Exception as e:
  266. print('Back up : Error')
  267. print(e)
  268. back_time = 1
  269. threading.Timer(60 * 60 * back_time, back_up, [data_db_set]).start()
  270. def do_every_day():
  271. with get_db_connect() as conn:
  272. curs = conn.cursor()
  273. # 오늘의 날짜 불러오기
  274. time_today = get_time().split()[0]
  275. # vote 관리
  276. curs.execute(db_change('select id, type from vote where type = "open" or type = "n_open"'))
  277. for for_a in curs.fetchall():
  278. curs.execute(db_change('select data from vote where id = ? and name = "end_date" and type = "option"'), [for_a[0]])
  279. db_data = curs.fetchall()
  280. if db_data:
  281. time_db = db_data[0][0].split()[0]
  282. if time_today > time_db:
  283. curs.execute(db_change("update vote set type = ? where user = '' and id = ? and type = ?"), ['close' if for_a[1] == 'open' else 'n_close', for_a[0], for_a[1]])
  284. # ban 관리
  285. curs.execute(db_change("update rb set ongoing = '' where end < ? and end != '' and ongoing = '1'"), [get_time()])
  286. # auth 관리
  287. curs.execute(db_change('select id, data from user_set where name = "auth_date"'))
  288. db_data = curs.fetchall()
  289. for for_a in db_data:
  290. time_db = for_a[1].split()[0]
  291. if time_today > time_db:
  292. curs.execute(db_change("update user_set set data = 'user' where id = ? and name = 'acl'"), [for_a[0]])
  293. curs.execute(db_change('delete from user_set where name = "auth_date" and id = ?'), [for_a[0]])
  294. # acl 관리
  295. curs.execute(db_change("select doc_name, doc_rev, set_data from data_set where set_name = 'acl_date'"))
  296. db_data = curs.fetchall()
  297. for for_a in db_data:
  298. time_db = for_a[2].split()[0]
  299. if time_today > time_db:
  300. curs.execute(db_change("delete from acl where title = ? and type = ?"), [for_a[0], for_a[1]])
  301. curs.execute(db_change("delete from data_set where doc_name = ? and doc_rev = ? and set_name = 'acl_date'"), [for_a[0], for_a[1]])
  302. # ua 관리
  303. curs.execute(db_change('select data from other where name = "ua_expiration_date"'))
  304. db_data = curs.fetchall()
  305. if db_data and db_data[0][0] != '':
  306. time_db = int(number_check(db_data[0][0]))
  307. time_calc = datetime.date.today() - datetime.timedelta(days = time_db)
  308. time_calc = time_calc.strftime('%Y-%m-%d %H:%M:%S')
  309. curs.execute(db_change("delete from ua_d where today < ?"), [time_calc])
  310. # auth history 관리
  311. curs.execute(db_change('select data from other where name = "auth_history_expiration_date"'))
  312. db_data = curs.fetchall()
  313. if db_data and db_data[0][0] != '':
  314. time_db = int(number_check(db_data[0][0]))
  315. time_calc = datetime.date.today() - datetime.timedelta(days = time_db)
  316. time_calc = time_calc.strftime('%Y-%m-%d %H:%M:%S')
  317. curs.execute(db_change("delete from re_admin where time < ?"), [time_calc])
  318. # 사이트맵 생성 관리
  319. curs.execute(db_change('select data from other where name = "sitemap_auto_make"'))
  320. db_data = curs.fetchall()
  321. if db_data and db_data[0][0] != '':
  322. main_setting_sitemap(1)
  323. print('Make sitemap')
  324. # 칭호 관리
  325. curs.execute(db_change("select id from user_set where name = 'user_title' and data = '✅'"))
  326. for for_a in curs.fetchall():
  327. if acl_check('', 'all_admin_auth', '', for_a[0]) == 1:
  328. curs.execute(db_change("update user_set set data = '☑️' where name = 'user_title' and data = '✅' and id = ?"), [for_a[0]])
  329. threading.Timer(60 * 60 * 24, do_every_day).start()
  330. def auto_do_something(data_db_set):
  331. if data_db_set['type'] == 'sqlite':
  332. back_up(data_db_set)
  333. do_every_day()
  334. auto_do_something(data_db_set)
  335. print('Now running... http://localhost:' + server_set['port'])
  336. @app.before_request
  337. def before_request_func():
  338. with class_temp_db() as m_conn:
  339. m_curs = m_conn.cursor()
  340. m_curs.execute('select data from temp where name = "wiki_access_password"')
  341. db_data = m_curs.fetchall()
  342. if db_data:
  343. access_password = db_data[0][0]
  344. input_password = flask.request.cookies.get('opennamu_wiki_access', ' ')
  345. if url_pas(access_password) != input_password:
  346. with get_db_connect() as conn:
  347. return '''
  348. <script>
  349. "use strict";
  350. function opennamu_do_wiki_access() {
  351. let password = document.getElementById('wiki_access').value;
  352. document.cookie = 'opennamu_wiki_access=' + encodeURIComponent(password) + '; path=/;';
  353. history.go(0);
  354. }
  355. </script>
  356. <h2>''' + get_lang(conn, 'error_password_require_for_wiki_access') + '''</h2>
  357. <input type="password" id="wiki_access">
  358. <input type="submit" onclick="opennamu_do_wiki_access();">
  359. '''
  360. # Init-custom
  361. if os.path.exists('custom.py'):
  362. from custom import custom_run
  363. custom_run('error', app)
  364. # Func
  365. # Func-inter_wiki
  366. app.route('/filter/inter_wiki', defaults = { 'tool' : 'inter_wiki' })(filter_all)
  367. app.route('/filter/inter_wiki/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'inter_wiki' })(filter_all_add)
  368. app.route('/filter/inter_wiki/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'inter_wiki' })(filter_all_add)
  369. app.route('/filter/inter_wiki/del/<everything:name>', defaults = { 'tool' : 'inter_wiki' })(filter_all_delete)
  370. app.route('/filter/outer_link', defaults = { 'tool' : 'outer_link' })(filter_all)
  371. app.route('/filter/outer_link/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'outer_link' })(filter_all_add)
  372. app.route('/filter/outer_link/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'outer_link' })(filter_all_add)
  373. app.route('/filter/outer_link/del/<everything:name>', defaults = { 'tool' : 'outer_link' })(filter_all_delete)
  374. app.route('/filter/document', defaults = { 'tool' : 'document' })(filter_all)
  375. app.route('/filter/document/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'document' })(filter_all_add)
  376. app.route('/filter/document/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'document' })(filter_all_add)
  377. app.route('/filter/document/del/<everything:name>', defaults = { 'tool' : 'document' })(filter_all_delete)
  378. app.route('/filter/edit_top', defaults = { 'tool' : 'edit_top' })(filter_all)
  379. app.route('/filter/edit_top/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'edit_top' })(filter_all_add)
  380. app.route('/filter/edit_top/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'edit_top' })(filter_all_add)
  381. app.route('/filter/edit_top/del/<everything:name>', defaults = { 'tool' : 'edit_top' })(filter_all_delete)
  382. app.route('/filter/image_license', defaults = { 'tool' : 'image_license' })(filter_all)
  383. app.route('/filter/image_license/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'image_license' })(filter_all_add)
  384. app.route('/filter/image_license/del/<everything:name>', defaults = { 'tool' : 'image_license' })(filter_all_delete)
  385. app.route('/filter/template', defaults = { 'tool' : 'template' })(filter_all)
  386. app.route('/filter/template/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'template' })(filter_all_add)
  387. app.route('/filter/template/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'template' })(filter_all_add)
  388. app.route('/filter/template/del/<everything:name>', defaults = { 'tool' : 'template' })(filter_all_delete)
  389. app.route('/filter/edit_filter', defaults = { 'tool' : 'edit_filter' })(filter_all)
  390. app.route('/filter/edit_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'edit_filter' })(filter_all_add)
  391. app.route('/filter/edit_filter/add/<everything:name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'edit_filter' })(filter_all_add)
  392. app.route('/filter/edit_filter/del/<everything:name>', defaults = { 'tool' : 'edit_filter' })(filter_all_delete)
  393. app.route('/filter/email_filter', defaults = { 'tool' : 'email_filter' })(filter_all)
  394. app.route('/filter/email_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'email_filter' })(filter_all_add)
  395. app.route('/filter/email_filter/del/<everything:name>', defaults = { 'tool' : 'email_filter' })(filter_all_delete)
  396. app.route('/filter/file_filter', defaults = { 'tool' : 'file_filter' })(filter_all)
  397. app.route('/filter/file_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'file_filter' })(filter_all_add)
  398. app.route('/filter/file_filter/del/<everything:name>', defaults = { 'tool' : 'file_filter' })(filter_all_delete)
  399. app.route('/filter/name_filter', defaults = { 'tool' : 'name_filter' })(filter_all)
  400. app.route('/filter/name_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'name_filter' })(filter_all_add)
  401. app.route('/filter/name_filter/del/<everything:name>', defaults = { 'tool' : 'name_filter' })(filter_all_delete)
  402. app.route('/filter/extension_filter', defaults = { 'tool' : 'extension_filter' })(filter_all)
  403. app.route('/filter/extension_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'extension_filter' })(filter_all_add)
  404. app.route('/filter/extension_filter/del/<everything:name>', defaults = { 'tool' : 'extension_filter' })(filter_all_delete)
  405. # Func-list
  406. app.route('/list/document/old', defaults = { 'set_type' : 'old' })(list_old_page)
  407. app.route('/list/document/old/<int:num>', defaults = { 'set_type' : 'old' })(list_old_page)
  408. app.route('/list/document/new', defaults = { 'set_type' : 'new' })(list_old_page)
  409. app.route('/list/document/new/<int:num>', defaults = { 'set_type' : 'new' })(list_old_page)
  410. app.route('/list/document/no_link')(list_no_link)
  411. app.route('/list/document/no_link/<int:num>')(list_no_link)
  412. app.route('/list/document/acl')(list_acl)
  413. app.route('/list/document/acl/<int:arg_num>')(list_acl)
  414. app.route('/list/document/need')(list_please)
  415. app.route('/list/document/need/<int:arg_num>')(list_please)
  416. app.route('/list/document/all')(list_title_index)
  417. app.route('/list/document/all/<int:num>')(list_title_index)
  418. app.route('/list/document/long')(list_long_page)
  419. app.route('/list/document/long/<int:arg_num>')(list_long_page)
  420. app.route('/list/document/short', defaults = { 'tool' : 'short_page' })(list_long_page)
  421. app.route('/list/document/short/<int:arg_num>', defaults = { 'tool' : 'short_page' })(list_long_page)
  422. app.route('/list/file')(list_image_file)
  423. app.route('/list/file/<int:arg_num>')(list_image_file)
  424. app.route('/list/image', defaults = { 'do_type' : 1 })(list_image_file)
  425. app.route('/list/image/<int:arg_num>', defaults = { 'do_type' : 1 })(list_image_file)
  426. app.route('/list/admin')(list_admin)
  427. app.route('/list/admin/auth_use', methods = ['POST', 'GET'])(list_admin_auth_use)
  428. app.route('/list/admin/auth_use_page/<int:arg_num>/<everything:arg_search>', methods = ['POST', 'GET'])(list_admin_auth_use)
  429. app.route('/list/user')(list_user)
  430. app.route('/list/user/<int:arg_num>')(list_user)
  431. app.route('/list/user/check_submit/<name>')(list_user_check_submit)
  432. app.route('/list/user/check/<name>')(list_user_check)
  433. app.route('/list/user/check/<name>/<do_type>')(list_user_check)
  434. app.route('/list/user/check/<name>/<do_type>/<int:arg_num>')(list_user_check)
  435. app.route('/list/user/check/<name>/<do_type>/<int:arg_num>/<plus_name>')(list_user_check)
  436. app.route('/list/user/check/delete/<name>/<ip>/<time>/<do_type>', methods = ['POST', 'GET'])(list_user_check_delete)
  437. # Func-auth
  438. app.route('/auth/give', methods = ['POST', 'GET'])(give_auth)
  439. app.route('/auth/give_total', methods = ['POST', 'GET'])(give_auth)
  440. app.route('/auth/give/<user_name>', methods = ['POST', 'GET'])(give_auth)
  441. app.route('/auth/ban', methods = ['POST', 'GET'])(give_user_ban)
  442. app.route('/auth/ban/multiple', methods = ['POST', 'GET'], defaults = { 'ban_type' : 'multiple' })(give_user_ban)
  443. app.route('/auth/ban/<everything:name>', methods = ['POST', 'GET'])(give_user_ban)
  444. app.route('/auth/ban_cidr/<everything:name>', methods = ['POST', 'GET'], defaults = { 'ban_type' : 'cidr' })(give_user_ban)
  445. app.route('/auth/ban_regex/<everything:name>', methods = ['POST', 'GET'], defaults = { 'ban_type' : 'regex' })(give_user_ban)
  446. # /auth/list
  447. # /auth/list/add/<name>
  448. # /auth/list/delete/<name>
  449. app.route('/auth/list')(list_admin_group_2)
  450. app.route('/auth/list/add/<name>', methods = ['POST', 'GET'])(give_admin_groups)
  451. app.route('/auth/list/delete/<name>', methods = ['POST', 'GET'])(give_delete_admin_group_2)
  452. app.route('/auth/give/fix/<user_name>', methods = ['POST', 'GET'])(give_user_fix)
  453. app.route('/app_submit', methods = ['POST', 'GET'])(recent_app_submit_2)
  454. # /auth/history
  455. app.route('/recent_block')(list_recent_block)
  456. app.route('/recent_block/all')(list_recent_block)
  457. app.route('/recent_block/all/<int:num>')(list_recent_block)
  458. app.route('/recent_block/all/<int:num>/<everything:why>')(list_recent_block)
  459. app.route('/recent_block/user/<user_name>', defaults = { 'tool' : 'user' })(list_recent_block)
  460. app.route('/recent_block/user/<user_name>/<int:num>', defaults = { 'tool' : 'user' })(list_recent_block)
  461. app.route('/recent_block/admin/<user_name>', defaults = { 'tool' : 'admin' })(list_recent_block)
  462. app.route('/recent_block/admin/<user_name>/<int:num>', defaults = { 'tool' : 'admin' })(list_recent_block)
  463. app.route('/recent_block/regex', defaults = { 'tool' : 'regex' })(list_recent_block)
  464. app.route('/recent_block/regex/<int:num>', defaults = { 'tool' : 'regex' })(list_recent_block)
  465. app.route('/recent_block/cidr', defaults = { 'tool' : 'cidr' })(list_recent_block)
  466. app.route('/recent_block/cidr/<int:num>', defaults = { 'tool' : 'cidr' })(list_recent_block)
  467. app.route('/recent_block/private', defaults = { 'tool' : 'private' })(list_recent_block)
  468. app.route('/recent_block/private/<int:num>', defaults = { 'tool' : 'private' })(list_recent_block)
  469. app.route('/recent_block/ongoing', defaults = { 'tool' : 'ongoing' })(list_recent_block)
  470. app.route('/recent_block/ongoing/<int:num>', defaults = { 'tool' : 'ongoing' })(list_recent_block)
  471. app.route('/recent_change')(list_recent_change)
  472. app.route('/recent_changes')(list_recent_change)
  473. app.route('/recent_change/<int:num>/<set_type>')(list_recent_change)
  474. app.route('/recent_discuss', defaults = { 'tool' : 'normal' })(list_recent_discuss)
  475. app.route('/recent_discuss/<int:num>/<tool>')(list_recent_discuss)
  476. # Func-history
  477. app.route('/recent_edit_request')(recent_edit_request)
  478. app.route('/record/<name>', defaults = { 'tool' : 'record' })(recent_change)
  479. app.route('/record/<int:num>/<set_type>/<name>', defaults = { 'tool' : 'record' })(recent_change)
  480. app.route('/record/reset/<name>', methods = ['POST', 'GET'])(recent_record_reset)
  481. app.route('/record/topic/<name>')(recent_record_topic)
  482. app.route('/record/bbs/<name>', defaults = { 'tool' : 'record' })(bbs_w)
  483. app.route('/record/bbs_comment/<name>', defaults = { 'tool' : 'comment_record' })(bbs_w)
  484. app.route('/history/<everything:doc_name>', methods = ['POST', 'GET'])(list_history)
  485. app.route('/history_page/<int:num>/<set_type>/<everything:doc_name>', methods = ['POST', 'GET'])(list_history)
  486. app.route('/history_tool/<int(signed = True):rev>/<everything:name>')(recent_history_tool)
  487. app.route('/history_delete/<int(signed = True):rev>/<everything:name>', methods = ['POST', 'GET'])(recent_history_delete)
  488. app.route('/history_hidden/<int(signed = True):rev>/<everything:name>')(recent_history_hidden)
  489. app.route('/history_send/<int(signed = True):rev>/<everything:name>', methods = ['POST', 'GET'])(recent_history_send)
  490. app.route('/history_reset/<everything:name>', methods = ['POST', 'GET'])(recent_history_reset)
  491. app.route('/history_add/<everything:name>', methods = ['POST', 'GET'])(recent_history_add)
  492. # Func-view
  493. app.route('/xref/<everything:name>')(view_xref)
  494. app.route('/xref_page/<int:num>/<everything:name>')(view_xref)
  495. app.route('/xref_this/<everything:name>', defaults = { 'xref_type' : 2 })(view_xref)
  496. app.route('/xref_this_page/<int:num>/<everything:name>', defaults = { 'xref_type' : 2 })(view_xref)
  497. app.route('/doc_watch_list/<int:num>/<everything:name>')(w_watch_list)
  498. app.route('/doc_star_doc/<int:num>/<everything:name>', defaults = { 'do_type' : 'star_doc' })(w_watch_list)
  499. app.route('/raw/<everything:name>')(view_w_raw)
  500. app.route('/raw_acl/<everything:name>', defaults = { 'doc_acl' : 'on' })(view_w_raw)
  501. app.route('/raw_rev/<int(signed = True):rev>/<everything:name>')(view_w_raw)
  502. app.route('/diff/<int(signed = True):num_a>/<int(signed = True):num_b>/<everything:name>')(view_diff)
  503. app.route('/down/<everything:name>')(view_down)
  504. app.route('/acl_multiple', defaults = { 'multiple' : True }, methods = ['POST', 'GET'])(view_set)
  505. app.route('/acl/<everything:name>', methods = ['POST', 'GET'])(view_set)
  506. app.route('/w_from/<everything:name>', defaults = { 'do_type' : 'from' })(view_w)
  507. app.route('/w/<everything:name>')(view_w)
  508. app.route('/random')(view_random)
  509. # Func-edit
  510. app.route('/edit/<everything:name>', methods = ['POST', 'GET'])(edit)
  511. app.route('/edit_from/<everything:name>', methods = ['POST', 'GET'], defaults = { 'do_type' : 'load' })(edit)
  512. app.route('/edit_section/<int:section>/<everything:name>', methods = ['POST', 'GET'])(edit)
  513. app.route('/edit_request/<everything:name>', methods = ['POST', 'GET'])(edit_request)
  514. app.route('/edit_request_from/<everything:name>', defaults = { 'do_type' : 'from' }, methods = ['POST', 'GET'])(edit_request)
  515. # app.route('/edit_request_rev/<int:rev>/<everything:name>', methods = ['POST', 'GET'])(edit_request)
  516. app.route('/upload', methods = ['POST', 'GET'])(edit_upload)
  517. # 개편 예정
  518. app.route('/xref_reset/<everything:name>')(edit_backlink_reset)
  519. app.route('/delete/<everything:name>', methods = ['POST', 'GET'])(edit_delete)
  520. app.route('/delete_file/<everything:name>', methods = ['POST', 'GET'])(edit_delete_file)
  521. app.route('/delete_multiple', methods = ['POST', 'GET'])(edit_delete_multiple)
  522. app.route('/revert/<int:num>/<everything:name>', methods = ['POST', 'GET'])(edit_revert)
  523. app.route('/move/<everything:name>', methods = ['POST', 'GET'])(edit_move)
  524. app.route('/move_all')(edit_move_all)
  525. # Func-topic
  526. app.route('/topic/<everything:name>', methods = ['POST', 'GET'])(topic_list)
  527. app.route('/topic_page/<int:page>/<everything:name>', methods = ['POST', 'GET'])(topic_list)
  528. app.route('/thread/<int:topic_num>', methods = ['POST', 'GET'])(topic)
  529. app.route('/thread/0/<everything:doc_name>', defaults = { 'topic_num' : '0' }, methods = ['POST', 'GET'])(topic)
  530. app.route('/thread/<int:topic_num>/tool')(topic_tool)
  531. app.route('/thread/<int:topic_num>/setting', methods = ['POST', 'GET'])(topic_tool_setting)
  532. app.route('/thread/<int:topic_num>/acl', methods = ['POST', 'GET'])(topic_tool_acl)
  533. app.route('/thread/<int:topic_num>/delete', methods = ['POST', 'GET'])(topic_tool_delete)
  534. app.route('/thread/<int:topic_num>/change', methods = ['POST', 'GET'])(topic_tool_change)
  535. app.route('/thread/<int:topic_num>/comment/<int:num>/tool')(topic_comment_tool)
  536. app.route('/thread/<int:topic_num>/comment/<int:num>/notice')(topic_comment_notice)
  537. app.route('/thread/<int:topic_num>/comment/<int:num>/blind')(topic_comment_blind)
  538. app.route('/thread/<int:topic_num>/comment/<int:num>/raw')(view_raw)
  539. app.route('/thread/<int:topic_num>/comment/<int:num>/delete', methods = ['POST', 'GET'])(topic_comment_delete)
  540. # Func-user
  541. app.route('/change', methods = ['POST', 'GET'])(user_setting)
  542. app.route('/change/key')(user_setting_key)
  543. app.route('/change/key/delete')(user_setting_key_delete)
  544. app.route('/change/pw', methods = ['POST', 'GET'])(user_setting_pw)
  545. app.route('/change/head', methods = ['GET', 'POST'], defaults = { 'skin_name' : '' })(user_setting_head)
  546. app.route('/change/head/<skin_name>', methods = ['GET', 'POST'])(user_setting_head)
  547. app.route('/change/head_reset', methods = ['GET', 'POST'])(user_setting_head_reset)
  548. app.route('/change/skin_set')(user_setting_skin_set)
  549. app.route('/change/top_menu', methods = ['GET', 'POST'])(user_setting_top_menu)
  550. app.route('/change/user_name', methods = ['GET', 'POST'])(user_setting_user_name)
  551. app.route('/change/user_name/<user_name>', methods = ['GET', 'POST'])(user_setting_user_name)
  552. # 하위 호환용 S
  553. app.route('/skin_set')(user_setting_skin_set)
  554. # 하위 호환용 E
  555. app.route('/change/skin_set/main', methods = ['POST', 'GET'])(user_setting_skin_set_main)
  556. app.route('/user')(user_info)
  557. app.route('/user/<name>')(user_info)
  558. app.route('/challenge', methods = ['GET', 'POST'])(user_challenge)
  559. app.route('/rankup')(user_rankup)
  560. app.route('/edit_filter/<name>', methods = ['GET', 'POST'])(user_edit_filter)
  561. app.route('/count')(user_count)
  562. app.route('/count/<name>')(user_count)
  563. app.route('/alarm')(user_alarm)
  564. app.route('/alarm/delete')(user_alarm_delete)
  565. app.route('/alarm/delete/<int:id>')(user_alarm_delete)
  566. app.route('/watch_list', defaults = { 'tool' : 'watch_list' })(user_watch_list)
  567. app.route('/watch_list/<everything:name>', defaults = { 'tool' : 'watch_list' })(user_watch_list_name)
  568. app.route('/watch_list_from/<everything:name>', defaults = { 'tool' : 'watch_list_from' })(user_watch_list_name)
  569. app.route('/star_doc', defaults = { 'tool' : 'star_doc' })(user_watch_list)
  570. app.route('/star_doc/<everything:name>', defaults = { 'tool' : 'star_doc' })(user_watch_list_name)
  571. app.route('/star_doc_from/<everything:name>', defaults = { 'tool' : 'star_doc_from' })(user_watch_list_name)
  572. # 개편 보류중 S
  573. app.route('/change/email', methods = ['POST', 'GET'])(user_setting_email_2)
  574. app.route('/change/email/delete')(user_setting_email_delete)
  575. app.route('/change/email/check', methods = ['POST', 'GET'])(user_setting_email_check_2)
  576. # 개편 보류중 E
  577. # Func-login
  578. # 개편 예정
  579. # login -> login/2fa -> login/2fa/email with login_id
  580. # register -> register/email -> regiter/email/check with reg_id
  581. # pass_find -> pass_find/email with find_id
  582. app.route('/login', methods = ['POST', 'GET'])(login_login_2)
  583. app.route('/login/2fa', methods = ['POST', 'GET'])(login_login_2fa_2)
  584. app.route('/register', methods = ['POST', 'GET'])(login_register_2)
  585. app.route('/register/email', methods = ['POST', 'GET'])(login_register_email_2)
  586. app.route('/register/email/check', methods = ['POST', 'GET'])(login_register_email_check_2)
  587. app.route('/register/submit', methods = ['POST', 'GET'])(login_register_submit_2)
  588. app.route('/login/find')(login_find)
  589. app.route('/login/find/key', methods = ['POST', 'GET'])(login_find_key)
  590. app.route('/login/find/email', methods = ['POST', 'GET'], defaults = { 'tool' : 'pass_find' })(login_find_email)
  591. app.route('/login/find/email/check', methods = ['POST', 'GET'], defaults = { 'tool' : 'check_key' })(login_find_email_check)
  592. app.route('/logout')(login_logout)
  593. # Func-vote
  594. app.route('/vote/<int:num>', methods = ['POST', 'GET'])(vote_select)
  595. app.route('/vote/end/<int:num>')(vote_end)
  596. app.route('/vote/close/<int:num>')(vote_close)
  597. app.route('/vote', defaults = { 'list_type' : 'normal' })(vote_list)
  598. app.route('/vote/list', defaults = { 'list_type' : 'normal' })(vote_list)
  599. app.route('/vote/list/<int:num>', defaults = { 'list_type' : 'normal' })(vote_list)
  600. app.route('/vote/list/close', defaults = { 'list_type' : 'close' })(vote_list)
  601. app.route('/vote/list/close/<int:num>', defaults = { 'list_type' : 'close' })(vote_list)
  602. app.route('/vote/add', methods = ['POST', 'GET'])(vote_add)
  603. # Func-bbs
  604. app.route('/bbs/main')(bbs_main)
  605. app.route('/bbs/make', methods = ['POST', 'GET'])(bbs_make)
  606. app.route('/bbs/in/<int:bbs_num>')(bbs_in)
  607. app.route('/bbs/in/<int:bbs_num>/<int:page>')(bbs_in)
  608. # app.route('/bbs/blind/<int:bbs_num>', methods = ['POST', 'GET'])(bbs_hide)
  609. app.route('/bbs/delete/<int:bbs_num>', methods = ['POST', 'GET'])(bbs_delete)
  610. app.route('/bbs/set/<int:bbs_num>', methods = ['POST', 'GET'])(bbs_w_set)
  611. app.route('/bbs/edit/<int:bbs_num>', methods = ['POST', 'GET'])(bbs_w_edit)
  612. app.route('/bbs/w/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_post)
  613. # app.route('/bbs/blind/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_hide)
  614. app.route('/bbs/pinned/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_pinned)
  615. app.route('/bbs/delete/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_delete)
  616. app.route('/bbs/raw/<int:bbs_num>/<int:post_num>')(view_raw)
  617. app.route('/bbs/tool/<int:bbs_num>/<int:post_num>')(bbs_w_tool)
  618. app.route('/bbs/edit/<int:bbs_num>/<int:post_num>', methods = ['POST', 'GET'])(bbs_w_edit)
  619. app.route('/bbs/tool/<int:bbs_num>/<int:post_num>/<comment_num>')(bbs_w_comment_tool)
  620. app.route('/bbs/raw/<int:bbs_num>/<int:post_num>/<comment_num>')(view_raw)
  621. app.route('/bbs/edit/<int:bbs_num>/<int:post_num>/<comment_num>', methods = ['POST', 'GET'])(bbs_w_edit)
  622. app.route('/bbs/delete/<int:bbs_num>/<int:post_num>/<comment_num>', methods = ['POST', 'GET'])(bbs_w_delete)
  623. # Func-api
  624. ## v1 API
  625. app.route('/api/render', methods = ['POST'])(api_w_render)
  626. app.route('/api/render/<tool>', methods = ['POST'])(api_w_render)
  627. app.route('/api/raw_exist/<everything:name>', defaults = { 'exist_check' : 'on' })(api_w_raw)
  628. app.route('/api/raw_rev/<int(signed = True):rev>/<everything:name>')(api_w_raw)
  629. app.route('/api/raw/<everything:name>')(api_w_raw)
  630. app.route('/api/xref/<int:page>/<everything:name>')(api_w_xref)
  631. app.route('/api/xref_this/<int:page>/<everything:name>', defaults = { 'xref_type' : '2' })(api_w_xref)
  632. app.route('/api/random')(api_w_random)
  633. app.route('/api/bbs/w/<sub_code>')(api_bbs_w)
  634. app.route('/api/bbs/w/comment/<sub_code>')(api_bbs_w_comment)
  635. app.route('/api/bbs/w/comment_one/<sub_code>')(api_bbs_w_comment_one)
  636. app.route('/api/version', defaults = { 'version_list' : version_list })(api_version)
  637. app.route('/api/skin_info')(api_skin_info)
  638. app.route('/api/skin_info/<name>')(api_skin_info)
  639. app.route('/api/user_info/<user_name>')(api_user_info)
  640. app.route('/api/thread/<int:topic_num>/<int:s_num>/<int:e_num>')(api_topic)
  641. app.route('/api/thread/<int:topic_num>/<tool>')(api_topic)
  642. app.route('/api/thread/<int:topic_num>')(api_topic)
  643. app.route('/api/search/<everything:name>')(api_func_search)
  644. app.route('/api/search_page/<int:num>/<everything:name>')(api_func_search)
  645. app.route('/api/search_data/<everything:name>', defaults = { 'search_type' : 'data' })(api_func_search)
  646. app.route('/api/search_data_page/<int:num>/<everything:name>', defaults = { 'search_type' : 'data' })(api_func_search)
  647. app.route('/api/recent_change')(api_list_recent_change)
  648. app.route('/api/recent_changes')(api_list_recent_change)
  649. app.route('/api/recent_change/<int:limit>')(api_list_recent_change)
  650. app.route('/api/recent_change/<int:limit>/<set_type>/<int:num>')(api_list_recent_change)
  651. app.route('/api/recent_edit_request')(api_list_recent_edit_request)
  652. app.route('/api/recent_edit_request/<int:limit>/<set_type>/<int:num>')(api_list_recent_edit_request)
  653. app.route('/api/recent_discuss/<set_type>/<int:limit>')(api_list_recent_discuss)
  654. app.route('/api/recent_discuss/<int:limit>')(api_list_recent_discuss)
  655. app.route('/api/recent_discuss')(api_list_recent_discuss)
  656. app.route('/api/lang', methods = ['POST'])(api_func_language)
  657. app.route('/api/lang/<data>')(api_func_language)
  658. app.route('/api/sha224/<everything:data>')(api_func_sha224)
  659. app.route('/api/ip/<everything:data>')(api_func_ip)
  660. app.route('/api/image/<everything:name>')(api_image_view)
  661. ## v2 API
  662. app.route('/api/v2/recent_edit_request/<set_type>/<int:num>', defaults = { 'limit' : 50 })(api_list_recent_edit_request)
  663. app.route('/api/v2/recent_change/<set_type>/<int:num>', defaults = { 'legacy' : '', 'limit' : 50 })(api_list_recent_change)
  664. app.route('/api/v2/recent_discuss/<set_type>/<int:num>', defaults = { 'legacy' : '', 'limit' : 50 })(api_list_recent_discuss)
  665. app.route('/api/v2/recent_block/<set_type>/<int:num>')(api_list_recent_block)
  666. app.route('/api/v2/recent_block/<set_type>/<int:num>/<everything:why>')(api_list_recent_block)
  667. app.route('/api/v2/recent_block_user/<set_type>/<int:num>/<user_name>')(api_list_recent_block)
  668. app.route('/api/v2/recent_block_user/<set_type>/<int:num>/<user_name>/<everything:why>')(api_list_recent_block)
  669. app.route('/api/v2/list/document/old/<int:num>', defaults = { 'set_type' : 'old' })(api_list_old_page)
  670. app.route('/api/v2/list/document/new/<int:num>', defaults = { 'set_type' : 'new' })(api_list_old_page)
  671. app.route('/api/v2/list/document/<int:num>')(api_list_title_index)
  672. app.route('/api/v2/list/auth')(api_list_auth)
  673. app.route('/api/v2/list/markup')(api_list_markup)
  674. app.route('/api/v2/list/acl/<data_type>')(api_list_acl)
  675. app.route('/api/v2/history/<int:num>/<set_type>/<everything:doc_name>')(api_list_history)
  676. app.route('/api/v2/topic/<int:num>/<set_type>/<everything:name>')(api_topic_list)
  677. app.route('/api/v2/bbs')(api_bbs_list)
  678. app.route('/api/v2/bbs/main')(api_bbs)
  679. app.route('/api/v2/bbs/set/<int:bbs_num>/<name>', methods = ['GET', 'PUT'])(api_bbs_w_set)
  680. app.route('/api/v2/bbs/in/<int:bbs_num>/<int:page>')(api_bbs)
  681. app.route('/api/v2/bbs/w/<sub_code>', defaults = { 'legacy' : '' })(api_bbs_w)
  682. app.route('/api/v2/bbs/w/tabom/<sub_code>', methods = ['GET', 'POST'])(api_bbs_w_tabom)
  683. app.route('/api/v2/bbs/w/comment/<sub_code>/<tool>', defaults = { 'legacy' : '' })(api_bbs_w_comment)
  684. app.route('/api/v2/bbs/w/comment_one/<sub_code>/<tool>', defaults = { 'legacy' : '' })(api_bbs_w_comment_one)
  685. app.route('/api/v2/doc_star_doc/<int:num>/<everything:name>', defaults = { 'do_type' : 'star_doc' })(api_w_watch_list)
  686. app.route('/api/v2/doc_watch_list/<int:num>/<everything:name>')(api_w_watch_list)
  687. app.route('/api/v2/set_reset/<everything:name>')(api_w_set_reset)
  688. app.route('/api/v2/page_view/<everything:name>')(api_w_page_view)
  689. app.route('/api/v2/setting/<name>', methods = ['GET', 'PUT'])(api_setting)
  690. app.route('/api/v2/auth')(api_func_auth)
  691. app.route('/api/v2/auth/<user_name>')(api_func_auth)
  692. app.route('/api/v2/auth/give', methods = ['PATCH'])(api_give_auth)
  693. app.route('/api/v2/user/rankup', methods = ['GET', 'PATCH'])(api_user_rankup)
  694. app.route('/api/v2/user/setting/editor', methods = ['GET', 'POST', 'DELETE'])(api_user_setting_editor)
  695. app.route('/api/v2/ip/<everything:data>', methods = ['GET', 'POST'])(api_func_ip)
  696. app.route('/api/v2/ip_menu/<everything:ip>', defaults = { 'option' : 'user' }, methods = ['GET', 'POST'])(api_func_ip_menu)
  697. app.route('/api/v2/user_menu/<everything:ip>')(api_func_ip_menu)
  698. app.route('/api/v2/lang', defaults = { 'legacy' : '' }, methods = ['POST'])(api_func_language)
  699. # Func-main
  700. # 여기도 전반적인 조정 시행 예정
  701. app.route('/other')(main_tool_other)
  702. app.route('/manager', methods = ['POST', 'GET'])(main_tool_admin)
  703. app.route('/manager/<int:num>', methods = ['POST', 'GET'])(main_tool_redirect)
  704. app.route('/manager/<int:num>/<everything:add_2>', methods = ['POST', 'GET'])(main_tool_redirect)
  705. app.route('/redirect_to/<int:n>')(main_redirect)
  706. app.route('/search', methods=['POST'])(main_search)
  707. app.route('/search/<everything:name>', methods = ['POST', 'GET'])(main_search_deep)
  708. app.route('/search_page/<int:num>/<everything:name>', methods = ['POST', 'GET'])(main_search_deep)
  709. app.route('/search_data/<everything:name>', defaults = { 'search_type' : 'data' }, methods = ['POST', 'GET'])(main_search_deep)
  710. app.route('/search_data_page/<int:num>/<everything:name>', defaults = { 'search_type' : 'data' }, methods = ['POST', 'GET'])(main_search_deep)
  711. app.route('/goto', methods=['POST'])(main_search_goto)
  712. app.route('/goto/<everything:name>', methods=['GET', 'POST'])(main_search_goto)
  713. app.route('/setting')(main_setting)
  714. app.route('/setting/main', methods = ['POST', 'GET'])(main_setting_main)
  715. app.route('/setting/main/logo', methods = ['POST', 'GET'])(main_setting_main_logo)
  716. app.route('/setting/top_menu', methods = ['POST', 'GET'])(main_setting_top_menu)
  717. app.route('/setting/phrase', methods = ['POST', 'GET'])(main_setting_phrase)
  718. app.route('/setting/head', defaults = { 'num' : 3 }, methods = ['POST', 'GET'])(main_setting_head)
  719. app.route('/setting/head/<skin_name>', defaults = { 'num' : 3 }, methods = ['POST', 'GET'])(main_setting_head)
  720. app.route('/setting/body/top', defaults = { 'num' : 4 }, methods = ['POST', 'GET'])(main_setting_head)
  721. app.route('/setting_preview/body/top', defaults = { 'num' : 4, 'set_preview' : 1 }, methods = ['POST'])(main_setting_head)
  722. app.route('/setting/body/bottom', defaults = { 'num' : 7 }, methods = ['POST', 'GET'])(main_setting_head)
  723. app.route('/setting_preview/body/bottom', defaults = { 'num' : 7, 'set_preview' : 1 }, methods = ['POST'])(main_setting_head)
  724. app.route('/setting/robot', methods = ['POST', 'GET'])(main_setting_robot)
  725. app.route('/setting/external', methods = ['POST', 'GET'])(main_setting_external)
  726. app.route('/setting/sitemap', methods = ['POST', 'GET'])(main_setting_sitemap)
  727. app.route('/setting/sitemap_set', methods = ['POST', 'GET'])(main_setting_sitemap_set)
  728. app.route('/setting/skin_set', methods = ['POST', 'GET'])(main_setting_skin_set)
  729. app.route('/setting/404_page', methods = ['POST', 'GET'])(setting_404_page)
  730. app.route('/easter_egg')(main_func_easter_egg)
  731. # views -> view
  732. app.route('/view/<path:name>')(main_view)
  733. app.route('/views/<path:name>')(main_view)
  734. app.route('/image/<path:name>')(main_view_image)
  735. # 조정 계획 중
  736. app.route('/<regex("[^.]+\\.(?:txt|xml|ico)"):data>')(main_view_file)
  737. app.route('/shutdown', methods = ['POST', 'GET'])(main_sys_shutdown)
  738. app.route('/restart', methods = ['POST', 'GET'])(main_sys_restart)
  739. app.route('/update', methods = ['POST', 'GET'])(main_sys_update)
  740. app.errorhandler(404)(main_func_error_404)
  741. def terminate_golang():
  742. if golang_process.poll() is None:
  743. golang_process.terminate()
  744. def signal_handler(signal, frame):
  745. terminate_golang()
  746. os._exit(0)
  747. signal.signal(signal.SIGTERM, signal_handler)
  748. signal.signal(signal.SIGINT, signal_handler)
  749. atexit.register(terminate_golang)
  750. if __name__ == "__main__":
  751. waitress.serve(
  752. app,
  753. host = server_set['host'],
  754. port = int(server_set['port']),
  755. clear_untrusted_proxy_headers = True
  756. )