-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyquickapache.py
More file actions
28 lines (23 loc) · 1009 Bytes
/
pyquickapache.py
File metadata and controls
28 lines (23 loc) · 1009 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
from flask import Flask
app = Flask(__name__)
serverName = "PyQuickApache"
errors = ['The server\'s homepage (index.html) was not found. If you are the developer of this site, make sure index.html is in the "static" folder.', 'The requested page couldn\'t be found.']
@app.route('/')
def index():
try:
f = open("static/index.html", 'r')
return str(f.read())
except Exception as e:
return f"<h1> {serverName} </h1> {errors[0]} <br> ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ <br> <i>Error Code 0</i> <br> <i>Returned by server: {e}"
@app.route('/<requestedPage>')
def returnPage(requestedPage):
try:
f = open(f"static/{requestedPage}", 'r')
return str(f.read())
except Exception as e:
return f"<h1> {serverName} </h1> {errors[1]} <br> ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ <br> <i>Error Code 1</i> <br> <i>Returned by server: {e}"
if __name__ == "__main__":
app.run(
debug=True,
port=80
)