Open jyn514 opened 6 years ago
My fix was to just pass the file texts as a string. No code file should be so long that it’s a huge issue at least for now. (Since our purpose is instruction)
This doesn't work for any sort of binary file. I know this is primarily for instruction, but it will crash on pictures, databases, anything that isn't valid unicode.
Traceback:
127.0.0.1 - - [19/May/2018 16:19:11] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [19/May/2018 16:19:13] "GET /?project=Colahacks HTTP/1.1" 200 -
127.0.0.1 - - [19/May/2018 16:19:14] "GET /?codefile=.backupzips%2Fcppdemo1.zip HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/joshua/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/joshua/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/joshua/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/joshua/Documents/Programming/Python/Colahacks/index.py", line 154, in main
other_vars['code_file'] = cfile.read()
File "/usr/lib64/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 11: invalid start byte
Docs
I was trying to run
{% include <filepath> %}
intemplates/index.html
. Unfortunately,jinja
gives an error that the file doesn't exist even when it's there because it doesn't support arbitrary file paths. My current workaround is to putln -s / root
intemplates
and{% include 'root/' + <filepath> %}
, which is hardly ideal.The easiest way to fix this is just have snaps in the working directory, but I like the idea of having a global cache. Still considering how to implement this.
Traceback