Re: [Tutor] Unexpected result when running flask application.

2019-06-19 Thread Cameron Simpson

On 19Jun2019 09:54, Alan Gauld  wrote:

On 19/06/2019 05:18, Cravan wrote:
I am experiencing an unexpected result when I try to 
run my flask application.

The movie.html page prints out nothing except those in the . This appears 
on my webpage:


Note that the mail server does not allow (for security reasons)
binary attachments so we lost your image.


Cravan, you might find it useful to "View Source" of that page in your 
browser.


You can also use command line tools like "curl" or "wget" to directly 
fetch the page content.



However, your html files are not in HTML.
I'm not a Flask expert but every time I've used Flask the
html pages have been real HTML. Yours appear to be in some
strange pseudo markup language.


It is very common in Flask to write HTML pages using Jinja templates, 
which is what his examples look like.


Of course this adds more complexity, if he forgets to use Jinja to 
render the content to HTML before returning it.



If this is something unique to Flask then I suspect you will
need to ask on a Flask support page or list. It doesn't seem
to be a Python language related issue at this point.


He has, as it happens, over in fl...@python.org.

Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unexpected result when running flask application.

2019-06-19 Thread Alan Gauld via Tutor
On 19/06/2019 05:18, Cravan wrote:
> Hi all,
> 
> I am experiencing an unexpected result when I try to run my 
> flask application. 
> The movie.html page prints out nothing except those in the . This appears 
> on my webpage:

Note that the mail server does not allow (for security reasons)
binary attachments so we lost your image.

However, your html files are not in HTML.
I'm not a Flask expert but every time I've used Flask the
html pages have been real HTML. Yours appear to be in some
strange pseudo markup language.

If this is something unique to Flask then I suspect you will
need to ask on a Flask support page or list. It doesn't seem
to be a Python language related issue at this point.

And your layout.html template is virtually empty.
I think you need to write some valid HTML somewhere.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Unexpected result when running flask application.

2019-06-19 Thread Cravan
Hi all,

I am experiencing an unexpected result when I try to run my 
flask application. The movie.html page prints out nothing except those in the 
. This appears on my webpage:

I want it to print out all the stuff related to the movie in my sql table, e.g. 
year, runtime etc. How should I modify my code then? Also, when trying out 
search.html, it prints method not allowed for the requested URL. How should I 
rectify this?

Cravan

 

   {% extends "layout.html" %} {% block title %}

  ERROR 404 NOT FOUND

   [1]Retry!

   {% endblock %} {% block body %}

  ERROR 404 NOT FOUND

   {{message}} {% endblock %}

References

   Visible links
   1. file:///tmp/{{ url_for('login') }}
   {% extends "layout.html" %} {% block title %}

  ERROR 404 NOT FOUND

   [1]Retry!

   {% endblock %} {% block body %}

  ERROR 404 NOT FOUND

   [2]Logout!

   {{message}} {% endblock %}

References

   Visible links
   1. file:///tmp/{{ url_for('movies') }}
   2. file:///tmp/{{ url_for('logout') }}
   {% extends "layout.html" %} {% block title %} Login/Registration {%
   endblock %} {% block body %}

  Hi, welcome to Movie Reviewer. This website is created by yourfavouriteguy.
Kindly Login or Register first!

   Username:
   [1]_
   Password:
   [2]_
   [3]Confirm Registration!

   If you have registered, please login!
   Name:
   [4]_
   Password:
   [5]_
   [6]Login!
  {% block body %} {% endblock %}
   {% extends "layout.html" %} {% block title %} {% endblock %} {% block body
   %}

 Movie Details

   {% for lol in movie_title %}

 Title: {{lol.title}}
 Year: {{lol.year}}
 Runtime: {{lol.runtime}}
 ImdbID: {{lol.imdbID}}
 ImdbRating: {{lol.imdbRating}}

   {% endfor %}

   [1]Back!

   {% endblock %}

   [2]Logout!

References

   Visible links
   1. file:///tmp/{{ url_for('movies') }}
   2. file:///tmp/{{ url_for('logout') }}
   {% block body %}

 All Movies Related to Search:

 {% for movie in movie_specific %}
 * [1]Here's a movie called {{movie.title}} and lasts for
   {{movie.runtime}} minutes. It was shot in the year {{movie.year}} and
   has the imdbID of {{movie.imdbID}}. Its rating is
   {{movie.imdbRating}}. {% endfor %}

   [2]Back!

   [3]Logout!

   {% endblock %}

References

   Visible links
   1. file:///tmp/{{ url_for('movie', movie_title = movie.title) }}
   2. file:///tmp/{{ url_for('movies') }}
   3. file:///tmp/{{ url_for('logout') }}
   {% extends "layout.html" %} {% block title %} Movies {% endblock %} {%
   block body %}

   All Movies

   [1]Search for a movie

 {% for movie in movies %}
 * [2]Here's a movie called {{movie.title}} and lasts for
   {{movie.runtime}} minutes. It was shot in the year {{movie.year}} and
   has the imdbID of {{movie.imdbID}}. Its rating is
   {{movie.imdbRating}}. {% endfor %}

   [3]Logout!

   {% endblock %}

References

   Visible links
   1. file:///tmp/search.html
   2. file:///tmp/{{ url_for('movie', movie_title=movie) }}
   3. file:///tmp/{{ url_for('logout') }}
   {% extends "layout.html" %} {% block title %} {% endblock %} {% block body
   %}

Search:

   [1]_
   {% endblock %}

References

   Visible links
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to Scrape Text from PDFs

2019-06-19 Thread Malcolm Herbert
This isn't  a response that's python-related, sorry, I'm still learning python 
myself, but more questions around the nature of the PDF and where I might start 
looking to solve the problem, were it mine.

The URLs that you are intending to match - are they themselves clickable when 
you open the PDF in another reader?  If so, then you might have better luck 
looking for the PDF element that provides that capability rather than trying to 
text-scrape to recover them.

Although unlikely inside a URL, text in a PDF can be laid out on the page in a 
completely arbitrary manner and to properly do PDF-to-text conversion you may 
need to track position on the page for each glyph as well as the font mapping 
vector - a glyph of an 'A' for instance might not actually be mapped to the 
ASCII/Unicode for 'A' ... all of which can make this a complete nightmare for 
the unwary.

So - when I last looked at generating a PDF with a live link element, this was 
implemented as blue underlined text (to make it look like a link) with an 
invisible box placed over the top which contained the PDF magic to make that do 
what I wanted when the user clicked on it.

I would suspect that what you might want would be a Python library that can 
pull apart a PDF into it's structural elements and then hunt through there for 
the appropriate "URL box" or whatever it's called ...

Hope that helps,
Malcolm

-- 
Malcolm Herbert
m...@mjch.net
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor