-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (23 loc) · 745 Bytes
/
main.py
File metadata and controls
28 lines (23 loc) · 745 Bytes
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
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)
return generated_page
if __name__ == "__main__":
app.run()
print(engine.export_internet())