-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
762 lines (588 loc) · 23 KB
/
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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# Load
import os
import re
# Setup
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
for i_data in os.listdir("route"):
f_src = re.search(r"(.+)\.py$", i_data)
if f_src:
f_src = f_src.group(1)
exec("from route." + f_src + " import *")
# Version
version_list = json.loads(open('version.json', encoding = 'utf8').read())
print('Version : ' + version_list['beta']['r_ver'])
print('DB set version : ' + version_list['beta']['c_ver'])
print('Skin set version : ' + version_list['beta']['s_ver'])
print('----')
# DB
while 1:
try:
set_data = json.loads(open('data/set.json', encoding = 'utf8').read())
if not 'db_type' in set_data:
try:
os.remove('data/set.json')
except:
print('Please delete set.json')
print('----')
raise
else:
print('DB name : ' + set_data['db'])
print('DB type : ' + set_data['db_type'])
break
except:
if os.getenv('NAMU_DB') != None or os.getenv('NAMU_DB_TYPE') != None:
set_data = {
"db" : os.getenv('NAMU_DB') if os.getenv('NAMU_DB') else 'data',
"db_type" : os.getenv('NAMU_DB_TYPE') if os.getenv('NAMU_DB_TYPE') else 'sqlite'
}
print('DB name : ' + set_data['db'])
print('DB type : ' + set_data['db_type'])
break
else:
new_json = ['', '']
normal_db_type = ['sqlite', 'mysql']
print('DB type (sqlite) [sqlite, mysql] : ', end = '')
new_json[0] = str(input())
if new_json[0] == '' or not new_json[0] in normal_db_type:
new_json[0] = 'sqlite'
all_src = []
for i_data in os.listdir("."):
f_src = re.search(r"(.+)\.db$", i_data)
if f_src:
all_src += [f_src.group(1)]
if all_src != [] and new_json[0] != 'mysql':
print('DB name (data) [' + ', '.join(all_src) + '] : ', end = '')
else:
print('DB name (data) : ', end = '')
new_json[1] = str(input())
if new_json[1] == '':
new_json[1] = 'data'
with open('data/set.json', 'w', encoding = 'utf8') as f:
f.write('{ "db" : "' + new_json[1] + '", "db_type" : "' + new_json[0] + '" }')
set_data = json.loads(open('data/set.json', encoding = 'utf8').read())
break
db_data_get(set_data['db_type'])
if set_data['db_type'] == 'mysql':
try:
set_data_mysql = json.loads(open('data/mysql.json', encoding = 'utf8').read())
except:
new_json = {}
while 1:
print('DB user ID : ', end = '')
new_json['user'] = str(input())
if new_json['user'] != '':
break
while 1:
print('DB password : ', end = '')
new_json['password'] = str(input())
if new_json['password'] != '':
break
print('DB host (localhost) : ', end = '')
new_json['host'] = str(input())
new_json['host'] = 'localhost' if new_json['host'] == '' else new_json['host']
print('DB port (3306) : ', end = '')
new_json['port'] = str(input())
new_json['port'] = '3306' if new_json['port'] == '' else new_json['port']
with open('data/mysql.json', 'w', encoding = 'utf8') as f:
f.write(json.dumps(new_json))
set_data_mysql = new_json
conn = pymysql.connect(
host = set_data_mysql['host'] if 'host' in set_data_mysql else 'localhost',
user = set_data_mysql['user'],
password = set_data_mysql['password'],
charset = 'utf8mb4',
port = int(set_data_mysql['port']) if 'port' in set_data_mysql else 3306
)
curs = conn.cursor()
try:
curs.execute(db_change('create database ' + set_data['db'] + ' default character set utf8mb4;'))
except:
pass
conn.select_db(set_data['db'])
else:
conn = sqlite3.connect(set_data['db'] + '.db')
curs = conn.cursor()
load_conn(conn)
# DB init
create_data = {}
create_data['data'] = ['title', 'data', 'type']
create_data['cache_data'] = ['title', 'data', 'id']
create_data['history'] = ['id', 'title', 'data', 'date', 'ip', 'unique_id', 'send', 'leng', 'hide', 'type']
create_data['rc'] = ['id', 'title', 'date', 'type']
create_data['rd'] = ['title', 'sub', 'code', 'date', 'band', 'stop', 'agree', 'acl']
create_data['user'] = ['unique_id', 'id', 'pw', 'acl', 'date', 'encode', 'changed']
create_data['user_info'] = ['unique_id', 'name', 'email']
create_data['user_set'] = ['name', 'id', 'data']
create_data['user_application'] = ['id', 'pw', 'date', 'encode', 'question', 'answer', 'ip', 'ua', 'token', 'email']
create_data['topic'] = ['id', 'data', 'date', 'ip', 'block', 'top', 'code']
create_data['rb'] = ['block', 'end', 'today', 'blocker', 'why', 'band', 'login', 'ongoing']
create_data['back'] = ['title', 'link', 'type']
create_data['other'] = ['name', 'data', 'coverage']
create_data['alist'] = ['name', 'acl']
create_data['re_admin'] = ['who', 'what', 'time']
create_data['alarm'] = ['name', 'data', 'date']
create_data['ua_d'] = ['name', 'ip', 'ua', 'today', 'sub']
create_data['scan'] = ['user', 'title', 'type']
create_data['acl'] = ['title', 'data', 'type']
create_data['html_filter'] = ['html', 'kind', 'plus', 'plus_t']
create_data['vote'] = ['name', 'id', 'subject', 'data', 'user', 'type', 'acl']
for i in create_data:
try:
curs.execute(db_change('select test from ' + i + ' limit 1'))
except:
try:
curs.execute(db_change('create table ' + i + '(test longtext)'))
except:
curs.execute(db_change("alter table " + i + " add test longtext"))
setup_tool = 0
try:
curs.execute(db_change('select data from other where name = "ver"'))
ver_set_data = curs.fetchall()
if not ver_set_data:
setup_tool = 2
else:
if int(version_list['beta']['c_ver']) > int(ver_set_data[0][0]):
setup_tool = 1
except:
setup_tool = 2
if setup_tool != 0:
for create_table in create_data:
for create in create_data[create_table]:
try:
curs.execute(db_change('select ' + create + ' from ' + create_table + ' limit 1'))
except:
try:
curs.execute(db_change("alter table " + create_table + " add " + create + " longtext default ''"))
except:
curs.execute(db_change("alter table " + create_table + " add " + create + " longtext"))
if setup_tool == 1:
update(int(ver_set_data[0][0]), set_data)
else:
set_init()
curs.execute(db_change('delete from other where name = "ver"'))
curs.execute(db_change('insert into other (name, data) values ("ver", ?)'), [version_list['beta']['c_ver']])
conn.commit()
# Init
logging.basicConfig(level = logging.ERROR)
app = flask.Flask(__name__, template_folder = './')
app.config['JSON_AS_ASCII'] = False
flask_reggie.Reggie(app)
class EverythingConverter(werkzeug.routing.PathConverter):
regex = '.*?'
app.jinja_env.filters['md5_replace'] = md5_replace
app.jinja_env.filters['load_lang'] = load_lang
app.jinja_env.filters['cut_100'] = cut_100
app.url_map.converters['everything'] = EverythingConverter
curs.execute(db_change('select name from alist where acl = "owner"'))
if not curs.fetchall():
curs.execute(db_change('insert into alist (name, acl) values ("owner", "owner")'))
curs.execute(db_change('select data from other where name = "image_where"'))
app_var = curs.fetchall()
if not app_var:
curs.execute(db_change('insert into other (name, data) values ("image_where", "data/images")'))
app_var = { 'path_data_image' : 'data/images' }
else:
app_var = { 'path_data_image' : app_var[0][0] }
if not os.path.exists(app_var['path_data_image']):
os.makedirs(app_var['path_data_image'])
if not os.path.exists('views'):
os.makedirs('views')
print('----')
import route.tool.init as server_init
dislay_set_key = ['Host', 'Port', 'Language', 'Markup', 'Encryption method']
server_set_key = ['host', 'port', 'language', 'markup', 'encode']
server_set = {}
for i in range(len(server_set_key)):
curs.execute(db_change('select data from other where name = ?'), [server_set_key[i]])
server_set_val = curs.fetchall()
if not server_set_val:
server_set_val = server_init.init(server_set_key[i])
curs.execute(db_change('insert into other (name, data) values (?, ?)'), [server_set_key[i], server_set_val])
conn.commit()
else:
server_set_val = server_set_val[0][0]
print(dislay_set_key[i] + ' : ' + server_set_val)
server_set[server_set_key[i]] = server_set_val
print('----')
curs.execute(db_change('select data from other where name = "key"'))
rep_data = curs.fetchall()
if not rep_data:
rep_key = ''.join(random.choice("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") for i in range(16))
if rep_key:
curs.execute(db_change('insert into other (name, data) values ("key", ?)'), [rep_key])
else:
rep_key = rep_data[0][0]
if set_data['db_type'] == 'sqlite':
def back_up():
print('----')
curs.execute(db_change('select data from other where name = "backup_where"'))
back_up_where = curs.fetchall()
if back_up_where and back_up_where[0][0] != '':
back_up_where = back_up_where[0][0]
else:
back_up_where = 'back_' + set_data['db'] + '.db'
try:
shutil.copyfile(
set_data['db'] + '.db',
back_up_where
)
print('Back up : OK')
except:
print('Back up : Error')
threading.Timer(60 * 60 * back_time, back_up).start()
try:
curs.execute(db_change('select data from other where name = "back_up"'))
back_up_time = curs.fetchall()
back_time = int(back_up_time[0][0])
except:
back_time = 0
if back_time != 0:
print('Back up state : ' + str(back_time) + ' hours')
back_up()
else:
print('Back up state : Turn off')
def mysql_dont_off():
try:
urllib.request.urlopen('http://localhost:' + server_set['port'] + '/')
except:
pass
threading.Timer(60 * 60 * 6, mysql_dont_off).start()
mysql_dont_off()
curs.execute(db_change('select data from other where name = "count_all_title"'))
if not curs.fetchall():
curs.execute(db_change('insert into other (name, data) values ("count_all_title", "0")'))
conn.commit()
print('Now running... http://localhost:' + server_set['port'])
if os.path.exists('custom.py'):
from custom import custom_run
custom_run(conn, app)
# Func
@app.route('/del_alarm')
def alarm_del():
return alarm_del_2(conn)
@app.route('/alarm')
def alarm():
return alarm_2(conn)
@app.route('/<regex("inter_wiki|edit_top|image_license|(?:edit|email|file|name|extension)_filter"):tools>')
def inter_wiki(tools = None):
return inter_wiki_2(conn, tools)
@app.route('/<regex("del_(?:inter_wiki|edit_top|image_license|(?:edit|email|file|name|extension)_filter)"):tools>/<name>')
def inter_wiki_del(tools = None, name = None):
return inter_wiki_del_2(conn, tools, name)
@app.route('/<regex("plus_(?:inter_wiki|edit_top|image_license|(?:edit|email|file|name|extension)_filter)"):tools>', methods=['POST', 'GET'])
@app.route('/<regex("plus_(?:inter_wiki|edit_top|image_license|(?:edit|email|file|name|extension)_filter)"):tools>/<name>', methods=['POST', 'GET'])
def inter_wiki_plus(tools = None, name = None):
return inter_wiki_plus_2(conn, tools, name)
@app.route('/setting')
@app.route('/setting/<int:num>', methods=['POST', 'GET'])
def setting(num = 0):
return setting_2(conn, num, set_data['db_type'])
@app.route('/not_close_topic')
def list_not_close_topic():
return list_not_close_topic_2(conn)
@app.route('/old_page')
def list_old_page():
return list_old_page_2(conn)
@app.route('/acl_list')
def list_acl():
return list_acl_2(conn)
@app.route('/image_file_list')
def list_image_file():
return list_image_file_2(conn)
@app.route('/admin_plus/<name>', methods=['POST', 'GET'])
def give_admin_groups(name = None):
return give_admin_groups_2(conn, name)
@app.route('/delete_admin_group/<name>', methods=['POST', 'GET'])
def delete_admin_group(name = None):
return delete_admin_group_2(conn, name)
@app.route('/admin_list')
def list_admin():
return list_admin_2(conn)
@app.route('/hidden/<everything:name>')
def give_history_hidden(name = None):
return give_history_hidden_2(conn, name)
@app.route('/add_history/<everything:name>', methods=['POST', 'GET'])
def give_history_add(name = None):
return give_history_add_2(conn, name)
@app.route('/user_log')
def list_user():
return list_user_2(conn)
@app.route('/admin_log', methods=['POST', 'GET'])
def list_admin_use():
return list_admin_use_2(conn)
@app.route('/give_log')
def list_give():
return list_give_2(conn)
@app.route('/restart', methods=['POST', 'GET'])
def server_restart():
return server_restart_2(conn)
@app.route('/update', methods=['GET', 'POST'])
def server_now_update():
return server_now_update_2(conn, version_list['beta']['r_ver'])
@app.route('/xref/<everything:name>')
def view_xref(name = None):
return view_xref_2(conn, name)
@app.route('/please')
def list_please():
return list_please_2(conn)
@app.route('/recent_discuss')
def recent_discuss():
return recent_discuss_2(conn)
@app.route('/block_log')
@app.route('/<regex("block_user|block_admin"):tool>/<name>')
def recent_block(name = None, tool = None):
return recent_block_2(conn, name, tool)
@app.route('/search', methods=['POST'])
def search():
return search_2(conn)
@app.route('/goto', methods=['POST'])
@app.route('/goto/<everything:name>', methods=['POST'])
def search_goto(name = 'test'):
return search_goto_2(conn, name)
@app.route('/search/<everything:name>')
def search_deep(name = 'test'):
return search_deep_2(conn, name)
@app.route('/raw/<everything:name>')
@app.route('/thread/<int:topic_num>/raw/<int:num>')
def view_raw(name = None, topic_num = None, num = None):
return view_raw_2(conn, name, topic_num, num)
@app.route('/revert/<everything:name>', methods=['POST', 'GET'])
def edit_revert(name = None):
return edit_revert_2(conn, name)
@app.route('/edit/<everything:name>', methods=['POST', 'GET'])
def edit(name = 'Test'):
return edit_2(conn, name)
@app.route('/backlink_reset/<everything:name>')
def edit_backlink_reset(name = 'Test'):
return edit_backlink_reset_2(conn, name)
@app.route('/delete/<everything:name>', methods=['POST', 'GET'])
def edit_delete(name = None):
return edit_delete_2(conn, name, app_var)
@app.route('/many_delete', methods=['POST', 'GET'])
def edit_many_delete(name = None):
return edit_many_delete_2(conn, app_var)
@app.route('/move/<everything:name>', methods=['POST', 'GET'])
def edit_move(name = None):
return edit_move_2(conn, name)
@app.route('/other')
def main_other():
return main_other_2(conn)
@app.route('/manager', methods=['POST', 'GET'])
@app.route('/manager/<int:num>', methods=['POST', 'GET'])
def main_manager(num = 1):
return main_manager_2(conn, num, version_list['beta']['r_ver'])
@app.route('/title_index')
def list_title_index():
return list_title_index_2(conn)
@app.route('/thread/<int:topic_num>/b/<int:num>')
def topic_block(topic_num = 1, num = 1):
return topic_block_2(conn, topic_num, num)
@app.route('/thread/<int:topic_num>/notice/<int:num>')
def topic_top(topic_num = 1, num = 1):
return topic_top_2(conn, topic_num, num)
@app.route('/thread/<int:topic_num>/setting', methods=['POST', 'GET'])
def topic_stop(topic_num = 1):
return topic_stop_2(conn, topic_num)
@app.route('/thread/<int:topic_num>/acl', methods=['POST', 'GET'])
def topic_acl(topic_num = 1):
return topic_acl_2(conn, topic_num)
@app.route('/thread/<int:topic_num>/delete', methods=['POST', 'GET'])
def topic_delete(topic_num = 1):
return topic_delete_2(conn, topic_num)
@app.route('/thread/<int:topic_num>/tool')
def topic_tool(topic_num = 1):
return topic_tool_2(conn, topic_num)
@app.route('/thread/<int:topic_num>/change', methods=['POST', 'GET'])
def topic_change(topic_num = 1):
return topic_change_2(conn, topic_num)
@app.route('/thread/<int:topic_num>/admin/<int:num>')
def topic_admin(topic_num = 1, num = 1):
return topic_admin_2(conn, topic_num, num)
@app.route('/thread/<int:topic_num>', methods=['POST', 'GET'])
def topic(topic_num = 1):
return topic_2(conn, topic_num)
@app.route('/topic/<everything:name>', methods=['POST', 'GET'])
def topic_close_list(name = 'test'):
return topic_close_list_2(conn, name)
@app.route('/tool/<name>')
def user_tool(name = None):
return user_tool_2(conn, name)
@app.route('/2fa_login', methods=['POST', 'GET'])
def login_2fa():
return login_2fa_2(conn)
@app.route('/login', methods=['POST', 'GET'])
def login():
return login_2(conn)
@app.route('/oauth_login', methods=['GET'])
def oauth_login():
return oauth_login_2(conn)
@app.route('/oauth_login_callback', methods=['GET'])
def oauth_login_back():
return oauth_login_callback_2(conn)
@app.route('/change', methods=['POST', 'GET'])
def user_setting():
return user_setting_2(conn, server_init)
@app.route('/pw_change', methods=['POST', 'GET'])
def login_pw_change():
return login_pw_change_2(conn)
@app.route('/check/<name>')
def give_user_check(name = None):
return give_user_check_2(conn, name)
@app.route('/check_delete', methods=['POST', 'GET'])
def give_user_check_delete():
return give_user_check_delete_2(conn)
@app.route('/<regex("need_email|pass_find|email_change"):tool>', methods=['POST', 'GET'])
def login_need_email(tool = 'pass_find'):
return login_need_email_2(conn, tool)
@app.route('/set_username', methods=['POST', 'GET'])
def login_set_username():
return login_set_username_2(conn)
@app.route('/<regex("check_key|check_pass_key|email_replace"):tool>', methods=['POST', 'GET'])
def login_check_key(tool = 'check_pass_key'):
return login_check_key_2(conn, tool)
@app.route('/logout')
def login_logout():
return login_logout_2(conn)
@app.route('/ban', methods=['POST', 'GET'])
@app.route('/ban/<name>', methods=['POST', 'GET'])
def give_user_ban(name = None):
return give_user_ban_2(conn, name)
@app.route('/acl/<everything:name>', methods=['POST', 'GET'])
def give_acl(name = None):
return give_acl_2(conn, name)
@app.route('/admin/<name>', methods=['POST', 'GET'])
def give_admin(name = None):
return give_admin_2(conn, name)
@app.route('/diff/<everything:name>')
def view_diff_data(name = None):
return view_diff_data_2(conn, name)
@app.route('/down/<everything:name>')
def view_down(name = None):
return view_down_2(conn, name)
@app.route('/w/<everything:name>')
def view_read(name = None):
return view_read_2(conn, name)
@app.route('/topic_record/<name>')
def list_user_topic(name = 'test'):
return list_user_topic_2(conn, name)
@app.route('/recent_changes')
@app.route('/<regex("record"):tool>/<name>')
@app.route('/<regex("history"):tool>/<everything:name>', methods=['POST', 'GET'])
def recent_changes(name = None, tool = 'record'):
return recent_changes_2(conn, name, tool)
@app.route('/history_tool/<everything:name>')
def recent_history_tool(name = None):
return recent_history_tool_2(conn, name)
@app.route('/history_delete/<everything:name>', methods=['POST', 'GET'])
def recent_history_delete(name = None):
return recent_history_delete_2(conn, name)
@app.route('/upload', methods=['GET', 'POST'])
def func_upload():
return func_upload_2(conn, app_var)
@app.route('/user')
def user_info():
return user_info_2(conn)
@app.route('/<regex("long_page|short_page"):tool>')
def list_long_page(tool = 'long_page'):
return list_long_page_2(conn, tool)
@app.route('/<regex("watch_list|star_doc"):tool>')
def watch_list(tool = 'star_doc'):
return watch_list_2(conn, tool)
@app.route('/<regex("watch_list|star_doc"):tool>/<everything:name>')
def watch_list_name(tool = 'star_doc', name = 'Test'):
return watch_list_name_2(conn, tool, name)
@app.route('/custom_head', methods=['GET', 'POST'])
def user_custom_head_view():
return user_custom_head_view_2(conn)
@app.route('/count')
@app.route('/count/<name>')
def user_count_edit(name = None):
return user_count_edit_2(conn, name)
@app.route('/random')
def func_title_random():
return func_title_random_2(conn)
@app.route('/image/<everything:name>')
def main_image_view(name = None):
return main_image_view_2(conn, name, app_var)
@app.route('/skin_set')
@app.route('/main_skin_set')
def main_skin_set():
return main_skin_set_2(conn)
@app.route('/application_submitted')
def application_submitted():
return application_submitted_2(conn)
@app.route('/applications', methods = ['POST', 'GET'])
def applications():
return applications_2(conn)
@app.route('/vote/<num>', methods=['POST', 'GET'])
def vote_select(num = '1'):
return vote_select_2(conn, num)
@app.route('/end_vote/<num>')
def vote_end(num = '1'):
return vote_end_2(conn, num)
@app.route('/close_vote/<num>')
def vote_close(num = '1'):
return vote_close_2(conn, num)
@app.route('/vote')
def vote():
return vote_2(conn)
@app.route('/add_vote', methods=['POST', 'GET'])
def vote_add():
return vote_add_2(conn)
# API
@app.route('/api/w/<everything:name>', methods=['POST', 'GET'])
def api_w(name = ''):
return api_w_2(conn, name)
@app.route('/api/raw/<everything:name>')
def api_raw(name = ''):
return api_raw_2(conn, name)
@app.route('/api/version')
def api_version():
return api_version_2(conn, version_list['beta']['r_ver'], version_list['beta']['c_ver'])
@app.route('/api/skin_info')
@app.route('/api/skin_info/<name>')
def api_skin_info(name = ''):
return api_skin_info_2(conn, name)
@app.route('/api/markup')
def api_markup():
return api_markup_2(conn)
@app.route('/api/user_info/<name>')
def api_user_info(name = ''):
return api_user_info_2(conn, name)
@app.route('/api/thread/<topic_num>')
def api_topic_sub(name = '', topic_num = 1):
return api_topic_sub_2(conn, topic_num)
@app.route('/api/search/<name>')
def api_search(name = ''):
return api_search_2(conn, name)
@app.route('/api/recent_changes')
def api_recent_change():
return api_recent_change_2(conn)
@app.route('/api/sha224/<everything:name>')
def api_sha224(name = 'test'):
return api_sha224_2(conn, name)
@app.route('/api/title_index')
def api_title_index():
return api_title_index_2(conn)
@app.route('/api/image/<everything:name>')
def api_image_view(name = ''):
return api_image_view_2(conn, name, app_var)
@app.route('/api/sitemap.xml')
def api_sitemap():
return api_sitemap_2(conn)
# File
@app.route('/views/<everything:name>')
def main_views(name = None):
return main_views_2(conn, name)
@app.route('/<data>')
def main_file(data = None):
return main_file_2(conn, data)
# End
@app.errorhandler(404)
def main_error_404(e):
return main_error_404_2(conn)
app.secret_key = rep_key
app.wsgi_app = werkzeug.debug.DebuggedApplication(app.wsgi_app, True)
app.debug = True
if __name__ == "__main__":
app.run(host = server_set['host'], port = int(server_set['port']), threaded = True)