forked from Sebby37/Dead-Internet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (25 loc) · 775 Bytes
/
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
import flask
from urllib.parse import urlparse
from ReaperEngine import *
app = flask.Flask(__name__)
engine = ReaperEngine()
@app.route("/", defaults={"path": ""})
@app.route("/<path:path>")
def index(path):
# Handle search and no seach
query = flask.request.args.get("query")
if not query and not path:
return engine.get_index()
if query and not path:
return engine.get_search(query)
if path == "_export":
return engine.export_internet()
# Generate the page
parsed_path = urlparse("http://" + path)
generated_page = engine.get_page(
parsed_path.netloc, path=parsed_path.path, query=parsed_path.query
)
return generated_page
if __name__ == "__main__":
app.run()
engine.export_internet()