Skip to content

Added files via upload #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ErrorDocument 404 /python/e.py?error=404
ErrorDocument 403 /python/e.py?error=403
#ErrorDocument 500 /python/e.py?error=500

RewriteEngine on
#RewriteRule ^([a-zA-Z0-9\-_/]*)$ index.py?cmd=$1
RewriteRule ^([a-zA-Z0-9\-\_\/]*)$ index.py?cmd=$1
15 changes: 15 additions & 0 deletions e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/Programs/Python34/python

import cgi
import os
import core.web

WEB_ROOT = os.environ["SCRIPT_NAME"].replace("e.py", "")
ROOT = os.environ["SCRIPT_FILENAME"].replace("e.py", "")
getMethod = cgi.FieldStorage()
error = getMethod.getvalue("error")
current_url = core.web.current_url()
if error is None or error != int:
core.web.redirect_url(WEB_ROOT+"error?code=404&url="+current_url)
elif error is int:
core.web.redirect_url(WEB_ROOT+"error?code="+error+"&url="+current_url)
39 changes: 39 additions & 0 deletions index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/Programs/Python34/python
import cgi
import os
import cgitb
import sys
from importlib.machinery import SourceFileLoader
import core.web as web

cgitb.enable()

WEB_ROOT = os.environ["SCRIPT_NAME"].replace("index.py", "")
ROOT = os.environ["SCRIPT_FILENAME"].replace("index.py", "")
getMethod = cgi.FieldStorage()
cmd = getMethod.getvalue("cmd")
html = ""
if cmd is None:
file = SourceFileLoader("home", "controllers/home.py").load_module()
controller = file.Controller
html = controller.index()
else:
params = getMethod.getvalue("cmd").split('/')
error_d = ROOT + "controllers/" + params[0] + ".py"
if params[0] != "" and params[0] != "error" and os.path.exists(ROOT + "controllers/" + params[0] + ".py"):
controller = params[0]
file = SourceFileLoader(params[0], "controllers/" + params[0] + ".py").load_module()
controller = file.Controller
html = controller.index()
elif params[0] != "" and params[0] != "error":
file = SourceFileLoader("special", "controllers/special.py").load_module()
controller = file.Controller
html = controller.index(params[0])
else:
file = SourceFileLoader("error", "controllers/error.py").load_module()
controller = file.Controller(WEB_ROOT)
# controller.WEB_ROOT = WEB_ROOT
html = controller.index()

html = html.format(bundle=web.bundles, **locals())
print(html)