educative-viewer icon indicating copy to clipboard operation
educative-viewer copied to clipboard

500 Internal Server Error

Open Diez15 opened this issue 2 years ago • 15 comments

When using the latest release of educative-viewer or when cloning the latest version and running the python script manually, I get the following error:

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

The server correctly lists all the items, but clicking on any of them I get the above error. The python trace is:

SNIP  - - [27/Jun/2023 13:12:59] "POST / HTTP/1.1" 302 -
[27/Jun/2023 13:12:59] "POST / HTTP/1.1" 302 -
[2023-06-27 13:12:59,982] ERROR in app: Exception on /145-replace [GET]
Traceback (most recent call last):
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "SNIP\educative-viewer\educative-viewer.py", line 131, in topics
    rendered_html = render_template(
  File "SNIP\eenv2\lib\site-packages\flask\templating.py", line 147, in render_template
    return _render(
  File "SNIP\eenv2\lib\site-packages\flask\templating.py", line 128, in _render
    rv = template.render(context)
  File "SNIP\eenv2\lib\site-packages\jinja2\environment.py", line 1291, in render
    self.environment.handle_exception()
  File "SNIP\eenv2\lib\site-packages\jinja2\environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "SNIP\educative-viewer\templates\topics.html", line 35, in top-level template code
    [([(=  include webpage =)])]
  File "SNIP\eenv2\lib\site-packages\jinja2\environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<unknown>", line 5, in template
jinja2.exceptions.TemplateSyntaxError: Missing end of comment tag
SNIP - - [27/Jun/2023 13:12:59] "GET /145-replace HTTP/1.1" 500 -
[2023-06-27 13:13:00,292] ERROR in app: Exception on /favicon.ico [GET]
Traceback (most recent call last):
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "SNIP\eenv2\lib\site-packages\flask\app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "SNIP\educative-viewer\educative-viewer.py", line 131, in topics
    rendered_html = render_template(
  File "SNIP\eenv2\lib\site-packages\flask\templating.py", line 147, in render_template
    return _render(
  File "SNIP\eenv2\lib\site-packages\flask\templating.py", line 128, in _render
    rv = template.render(context)
  File "SNIP\eenv2\lib\site-packages\jinja2\environment.py", line 1291, in render
    self.environment.handle_exception()
  File "SNIP\eenv2\lib\site-packages\jinja2\environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "SNIP\educative-viewer\templates\topics.html", line 35, in top-level template code
    [([(=  include webpage =)])]
  File "SNIP\eenv2\lib\site-packages\jinja2\environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<unknown>", line 5, in template
jinja2.exceptions.TemplateSyntaxError: Missing end of comment tag
SNIP - - [27/Jun/2023 13:13:00] "GET /favicon.ico HTTP/1.1" 500 -

I see that a similar issue was raised in the past and you marked it as fixed, but I am still getting the error. Can you provide any advice?

Diez15 avatar Jun 27 '23 10:06 Diez15

@anilabhadatta can you please take a look and help me resolve this issue? Thank you!

Diez15 avatar Jun 29 '23 09:06 Diez15

@Diez15 may have some special characters that are causing issues during rendering. Send me the Html file in a zip format here. Also tell me if it is causing for each topics? Video demonstration will be helpful

[([(= include webpage =)])]

This issue is mostly caused due to Latex or special characters in HTML file.

anilabhadatta avatar Jul 02 '23 19:07 anilabhadatta

@anilabhadatta - I'm facing a similar issue and was wondering if you had a solution for the same. I have cloned the repository and running it locally using a virtual environment. Unfortunately, it's happening with each and every page and I was wondering if you had a solution for the same?

course.zip

Thank You!

sahibdhanjal avatar Feb 15 '24 02:02 sahibdhanjal

@sahibdhanjal checking

anilabhadatta avatar Feb 15 '24 20:02 anilabhadatta

@sahibdhanjal the zip file you provided is having issues, you will need to re-scrape because i rescraped and it is working. also use dark mode during scraping

anilabhadatta avatar Feb 15 '24 20:02 anilabhadatta

Ahh, got it, I'll re-scrape. Thanks a lot for looking into it, really appreciate it 👍🏻

sahibdhanjal avatar Feb 15 '24 21:02 sahibdhanjal

@sahibdhanjal some updates were added as well. do pull

anilabhadatta avatar Mar 03 '24 22:03 anilabhadatta

Perfect, thanks man!

sahibdhanjal avatar Mar 05 '24 06:03 sahibdhanjal

The simplest fix for this bug is by changing the comment delimiters @ line 18-19 to this:

app.jinja_env.comment_start_string = "{[(#"
app.jinja_env.comment_end_string = "#)]}"

Thanks for the effort. The code is a bit hard to understand though at first sight. And the sidebar could be more transparent or automatically hidden so as not to obstruct the main view.

iexa avatar Mar 28 '24 15:03 iexa

@iexa thanks i will update the jinja bug. Also refer v3-dev branch. New features were added and regarding the sidebar, will look a look for enhancement. Also code is very unreadable at this moment, will fix it in coming days.

anilabhadatta avatar Mar 28 '24 15:03 anilabhadatta

If you have the capacity you could try adding a light mode as well, the stuff I got are all light mode-scraped unfortunately :(

Would be great to use rar or zip files as well - I mean using a (list of) compressed rar / zip files, as the main data source the same as you do now but with folders / files. python's build in zipfile plus the 3rd party rarfile module would be fine. Reading the archive you can build up a list of links and when the actual html file would be read then it would be unpacked (to the system's temp folder - and read from there).

Or if you can make the code more humanely understandable I can add these features to your code, as I was thinking on making the same but using clean code principles as much as possible.

iexa avatar Apr 02 '24 09:04 iexa

@iexa if you want you can make changes to the existing code. Changes should be made to dev branch. I am not getting much time to cleanup the code. I will try to do it. But if you want to participate then I will leave it up to you to refactor the code and the features that you want to implement.

But do remember the zip features should be an optional one, the current architecture should remain stable.

anilabhadatta avatar Apr 02 '24 15:04 anilabhadatta

@iexa currently i am busy fixing and implementing features in the scraper. I will see if i can make the code readable.

anilabhadatta avatar Apr 02 '24 15:04 anilabhadatta

The simplest fix for this bug is by changing the comment delimiters @ line 18-19 to this:

app.jinja_env.comment_start_string = "{[(#"
app.jinja_env.comment_end_string = "#)]}"

Thanks for the effort. The code is a bit hard to understand though at first sight. And the sidebar could be more transparent or automatically hidden so as not to obstruct the main view.

Thanks @iexa , this worked for me 👍🏻

sahibdhanjal avatar Apr 02 '24 20:04 sahibdhanjal

@iexa refer to the latest commit on v4-dev branch, a lot of cleanup was done, should help you now understanding the code.

anilabhadatta avatar Apr 07 '24 10:04 anilabhadatta