How to display youtube video on website using GAE - python

I am trying to include a youtube video on website that I'm developing using GAE and python.
I know I should use this<iframe width="420" height="345"
src="http://www.youtube.com/watch?v=MYSVMgRr6pw">
</iframe> in my HTML, but I am also guessing I have to make some changes in app.yaml file. I can't figure out how to amend my app.yaml correctly. Currently I can only see a square box and no video. Here is a link to a web page with a video http://www.firstpiproject.appspot.com/learninglinux
Thanks

I believe, per http://www.w3schools.com/html/html_youtube.asp, that the canonical form is something like, and I quote:
<iframe width="420" height="315"
src="http://www.youtube.com/embed/XGSy3_Czz8k">
</iframe>
Note the slightly different format for the src= URL, with .../embed/ -- your page has src="http://www.youtube.com/watch?v=hBvaB8aAp1I&feature=youtu.be", which is a somewhat-different format.
I don't think this has anything to do with App Engine, python, app.yaml, and the like -- it's all about what, exactly, you put in that src= parameter of the iframe you serve as part of your HTML page. Try the w3schools-recommended format with .../embed/... and let us know!

Related

how to find hidden video src using selenium?

In general, It is possible to download the video by right-click.
But I don't know how to find this video's src using selenium.
<div id="video-processing" class="video-processing hidden">Processing video, please check back in a while</div>
<video id="video-player" class="video-js vjs-default-skin hidden" controls preload="auto" width="640" height="264" poster="http://i3.ruliweb.com/profile/16/12/01/158b9f7cb02326425.jpeg"></video>
I needs your help. thanks.
I had a problem like your question,
If you can not find the src by Inspect by browser Or get the page source code by Python (For various reasons, such as controlling several quality of video or for security & police reasons) ➡
One hundred percent is being changed by JavaScript. Otherwise should have been visible in the HTML code.
So I have a very simple recommendation and that is to use this code in Console:
var x = document.getElementsById("video-player").getAttribute("src");
console.log(x);
alert(x);
Of course, it would be much better if you give the site Address.

Python - Want to change header logo based on url selection

I would like to change the logo of a website based on which menu is currently activated/seen by the user browsing the website.
For instance I have www.urltowebsite.com/menu1 = Header Logo 1
And then I have www.urltowebsite.com/menu2 = Header Logo 2
And on top of this I want to add an else statement stating that: If any other menu is selected, use header logo 3.
How can I make this possible with Python? I cant seem to wrap my head around what to define where and how to call up the different functions on the HTML website.
Oh and I insist doing this with Python. And preferably without any framework such as Django. But if needs be I can install web.py
EDIT:
Am I forced to go with php then? I would like to once and for all start utilizing Python on my web projects.
The website is made in simple HTML as I said first. The Javascript functions are only used to serve the HTML menu's through AJAX. Again this does not matter much for what I am trying to do, as menu's have classes and I can define those in php and thus change my logo/header.
What I want to do is to use Python in this instance. Here is a code snippet from the site:
<div id="header">
<span class="title"><img src="http://www.url.com/subfolder/images/logo.png"/>
</span>
</div>
And some more relevant to this:
<div id="menu">
<ul>
<li>001</li>
<li>002</li>
<li>003</li>
<li>004</li>
<li>005</li>
<li>006</li>
<li>007</li>
<li>008</li>
</ul>
</div>
So can I use python here?
You're asking to do the wrong thing the wrong way.
In order to change the logo based on the URL in Python , you need Python to generate the page and know what that url is.
There are two ways to do that in Python:
Use an existing Web Framework
Write your own Web Framework
"Python" doesn't know or care what your URL is - the frameworks and support libraries ( Django, Pyramid, Bottle, Flash, Tornado, Twisted, etc) figure out what the URL is by an integration with an underlying web server ( though some have their own webserver coupled in ). Similarly, PHP doesn't really know or care what the URL is - that information comes from an integration with Apache or FCGI/Nginx/etc. PHP tends to ship with most/all of that integration done. It's also worth noting that PHP is not just a language, but a web framework. Python is just a language.
Most Python frameworks will be written to the WSGI spec and have a "request" object that has all the data you want ( and many use the WebOb librbary for that ).
If you plan on doing everything with static HTML files, then you have a few options:
have a single static directory. use javascript to figure out the addressbar location, and render the corresponding logo / write the headers & footers.
have a "template" directory of all your HTML. use a Python script build a static version of each website with the custom headers/footers and configure your webserver to serve a different one for each domain.
No, Python cannot run inside the HTML web page. If you're really serving plain HTML pages then you must use javascript to execute code in the browser once the page is loaded. However, since you mention using AJAX, it sounds like it's not really true that you're serving plain HTML but rather have some server side code. If so, that server side code is the place to put your HTML-construction logic. To know the best way to do that, you would have to describe what's happening on the server.
Although I haven't used it, I have heard that the pyhp project more or less provides php-like embedded functionality for python.

Can I serve generated images without storing them on the server side?

I have a form where the user uploads two images, and based on them I generate about 10 other images ( using PIL ). The thing is, I want to show an HTML page that contains all the generated images, but I would like not to have to store them on server side. Is this possible?
You could use the Data URI scheme. The examples section on that Wikipedia article has some nice things to start with. What you need then, is to convert the binary image data to base64 so you can include it on your page. Fortunately, there are scripts available for this already.
Browser support seems okay, all major browser have no problem with it. For IE, it is supported from IE8 upwards (with IE8 having a limitation of 32KiB for the URI size).
You need to design your URLs correctly and have a view for an URL pointing to an image. In that view then you send the generated image. The Django website has an example for a PDF.
https://docs.djangoproject.com/en/1.3/howto/outputting-pdf/
In your (static?) HTML page you have a reference then like
<img src="/dyn_images/foo.png"/>
and an URL rule watching for that.

Python/Django: How to Prepend a # on to all URLS

I am building a mobile web app with Django and jQuery Mobile. My problem is that jQuery Mobile likes for all links to be prepended with a # so it can accurately keep track of browsing history.
Example: http://www.fest.com/#/foo/1/
I would like know how to automatically redirect all urls that point From: /foo/1/ To: /#/foo/1/
If I don't do that and someone goes directly to /foo/1/, then clicks a link pointing to /bar/2/, they'll end up with a URL path like this:
/foo/1/#/bar/2/
I would very much like to prevent that from happening because its causes lots of problems. Whats the best way to do this?
You have misunderstood what the # does.
The # in a URL is the "fragment" separator. Nothing after that is sent to the server. So there is no such URL as "foo. com#/foo" - as far as the server is concerned, it's just "foo.com". So you can't do any server-side redirection.
If your JS library is using the fragments to simulate navigation, you'll need to handle this with Javascript.
This is jquery mobile, so the answer is a bit different. Jquery mobile uses #something for history when working with AJAX. The AJAX call is introduced for every <a href=...
So you just link to a page like this: <a href="some.html?var1=foo" and JQM calls an ajax on it without reloading the page AND stores the item in the DOM document to not load again. The url is updated to have #some.html at the end and it's how the history is managed.
<a href="#something" WILL NOT work as in a normal page, because jquery mobile takes over.
Read here to get all info on links in jquery mobile: http://jquerymobile.com/demos/1.0a2/#docs/pages/link-formats.html

Embed Google Docs PDF viewer in IFRAME

When I upload PDF to Google Docs (using Python's gdata library), I get link to the document:
>>> e.GetAlternateLink().href
Out[14]: 'http://docs.google.com/a/my.dom.ain/fileview id=<veery-long-doc-id>&hl=en'
Unfortunately using that link in IFRAME is not working for me because PDF viewer is redirecting to itself, breaking out of IFRAME.
Looking for the solution, I've found this: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html - which looks very nice, but I can't find a way to use it with document uploaded to Google Docs. Does somebody know how to do it/if it's at all possible?
Just for the record - I haven't found any way to force "internal" google google pdf viewer to not go out of the iframe. And as I mentioned in the question, I found this nice standalone viewer: https://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html, that can be used like this:
<iframe src="https://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
-- but in order to use it you have to publish your PDF to the outside world. This wouldn't be a bad solution, because published document has unique id that is probably harder to guess than a password to google docs account. Unfortunately, even with hottest Google Docs API version 3 API, there seems to be no way of publishing PDF programatically..
In the end, I went for a mix of: standalone PDF viewer from google and some other web service that allows to programatically upload and publish PDF. A bit half-baked solution, but it works well so far.
To embed pdf files present in your google docs into your website use the below code:
<iframe src="http://docs.google.com/gview?a=v&pid=explorer&chrome=false&api=true&embedded=true&srcid=<id of your pdf>&hl=en&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
Try this!
Same as other answers above...
<iframe src="https://docs.google.com/gview?url={magical url that works}"></iframe>
except the magical url that works is https://drive.google.com/uc?id=<docId>&embedded=true.
Google Drive/Docs provides a bunch of different urls:
https://drive.google.com/open?id=<docId> Share link.
https://docs.google.com/document/<docId>/edit Open in Google Drive.
https://docs.google.com/document/d/<docId>/view Same as 'edit' above. I think.
https://docs.google.com/document/d/<docId>/pub?embedded=true For embedding in iframe if you File -> Publish to the web...
https://drive.google.com/uc?export=download&id=<docId> Direct download link.
I stumbed across this solution after a bunch of trial and error with different links. Hope this helps!
The Google Docs embedding in iframes via the viewer is problematic in IE8 if not already cached, and is is just not equal to the much better Scribd's facility that allows you to simply make a simple html page with the document embeded via their supplied object code for the document. I then use it as the source file for my iframe. It shows the print (and also a full screen button), right in the embedded frame page. Much more friendly and reliable for the page's visitors.
The following worked for me:
<iframe src="https://drive.google.com/viewerng/viewer?url=url_of_pdf?pid=explorer&efh=false&a=v&chrome=false&embedded=true" embedded=true></iframe>
Spent an hour on this, below worked:
Example:
<iframe src={`https://docs.google.com/gview?url=${encodeURIComponent('http://infolab.stanford.edu/pub/papers/google.pdf')}&embedded=true`}></iframe>
Note that encodeURIComponent was needed.

Categories