-
Notifications
You must be signed in to change notification settings - Fork 0
/
xss_main.py
74 lines (54 loc) · 1.52 KB
/
xss_main.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
from flask import Flask, request, abort, jsonify, render_template, redirect
import webbrowser
import requests
import threading
import os.path
import json
import time
import re
import os
import db
from datetime import datetime
app = Flask(__name__)
return_result = ''
def db_clean():
try:
db.delete_comments()
except Exception:
pass
@app.route('/', methods=['GET'])
def home():
return redirect('/index_1')
@app.route('/index_<page_id>', methods=['GET', 'POST'])
def index(page_id):
global return_result
if request.method == 'GET':
try:
return_result = request.args['query']
print(return_result)
except Exception as error:
print(error)
elif request.method == 'POST':
comment = request.form.get('comment')
current_time = datetime.now().strftime("%B %d, %Y %I:%M%p")
db.add_comment(comment, current_time)
comments = db.get_comments()
return render_template(
f'index_{page_id}.html',
return_result=return_result,
comments=comments,
)
@app.route('/index_<page_id>/dbclean', methods=['GET'])
def dbclean(page_id):
db_clean()
return redirect(f'/index_{page_id}')
@app.after_request
def add_header(response):
response.cache_control.max_age = 1
return response
def run_flask_app():
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port, debug=False, threaded=True)
if __name__ == "__main__":
t = threading.Thread(target=run_flask_app)
t.run()