I want a better way to update images on a webpage instead of forcing the webpage to refresh every 60 seconds.
I wrote a little status page that monitors some of our web sites. It uses web.py and displays a list of servers I have inputted into a database.
Each server that is up gets a Green png image displayed next to it.
When a server goes down I update the status in a local mysql database to false.
The next time the page refreshes it gets a red png displayed next to it.
Right now that red png file does not display until I refresh the page.
Is there a way in web.py (python) that I can make just that image dynamic without having to refresh the whole page? Or do I have to use something else to make it work?
Well, the generic answer is that you use AJAX and put a script on each server that will return "up" or something every time your page checks.
Here's a tutorial on how to do AJAX with web.py specifically: http://kooneiform.wordpress.com/2010/02/28/python-and-ajax-for-beginners-with-webpy-and-jquery/
I have no knowledge related to web.py.
But in my point of view what you gonna need is to break your code in two parts (a monitor service and a monitor display) and use javascript to asynchronously update the data.
Your monitor service will provide a url that receives the monitored site ID and returns up or down. As you are using web.py, it will probably be 100% python.
Your monitor display will use javascript to ever X seconds checks that url and show the correct icon. It can be python based, or not. But it will need javascript.
Related
Using angular and a server side data source, I want to be able to load the grid at a specific page number. This will help me support the user using the back button as they go from list pages (aggrid) to detail pages.
I've discovered paginationGoToPage() but it doesn't seem to work in onGridReady, it only works if i use it on a button click. But even if I do use it, it seems like the data would have to be loaded twice, once when the grid is first rendered and then again for the particular page I want to go to.
I want to know 'How to add wait or Delay until webpage is fully loaded,' in automations anywhere,
I used
wait for screen change
But it hold the process until some time specified by the developer , but I want to add delay until the web page fully loaded,
Is there anyone can help me?
sorry for the bad English.
Usually, a website is "loaded" or "ready" before the actual content is loaded. Some websites even have dummy content which is replaced once the actual content is retrieved from 'somewhere'. Hence waiting for the screen to change is not a good idea.
My approach is to pick an element which you know is loaded after the element you want to interact with. For instance the navigation bar on this website is loaded before the comments are. You can either figure out which element to use by looking at the source of the website by right-clicking anywhere and selecting view source or by simply refreshing the page a couple of times and eye-balling it. The former requires some HTML knowledge, but is a better approach in my opinion.
Once you've identified your element, use Object Cloning on said element and use the built-in wait as a delay (usually set to 15 sec, depending on the website/connection). The Action should be some random get property (store whatever you retrieve in some dummy variable as we're not going to use it anyway).
Object Cloning's wait function polls every so many milliseconds and once the element is found it will almost instantaneously go to the next line in the code. This is where you interact with your target element.
This way you know your target element is loaded and the code is very optimized and robust.
On a final note: It's usually a good idea to surround this with some exception handling as automating websites is prone to errors.
A very simple solution is to run your automation while watching and determine the amount of time it takes for the webpage to load. You can add a Delay rather than a wait if you know the page is generally loaded within 30 seconds or so.
I have just started to look into the phone gap.I have created one basic form which taking the data of the employee.I have table view in another screen .I want to pass the employee details to the second screen .I was googling for this purpose.I have found that there are some ways to do this like:
1.Server side post back
2. Client side URL examination
3.What's in a window.name = local cross-page session
4.HTML5 local storage
5. Cookies
But will my phone gap application be 100% native by using these ways? Is there any alternate way or tutorial to pass the data between the screens?
What you actually mean by "a screen"? If you're talking about a pop-up dialog box or page by jQuery Mobile you can probably serialize the form with jQuery and assign it to a JavaSCript variable.
But if you're changing your "screen" by changing UIView to a different url you can use either:
File API to store serialized form in a file and load it on the 2nd "screen"
Storage API to ... actually do the same
I'd go for number one, as it's easier to implement than using SQL and writing loads of additional code.
Search for:
jQuery.serialize()
PhoneGap File API
I have this gwt app which say, runs on http://mygwtapp.com/ (which is actually: http://mygwtapp.com/index.html)
The app host a database of users, queried by searching usernames using the search view and results are shown in the user results view. Pretty useful enough. However I need to bb add a way that user view can be viewed by just typing http://myapp.com/user123
I am thinking that the question I have here, the answer is a server side solution. However if there's a client side solution, please let me know.
One fellow here in StackOVerflow suggested that the format would be like this:
mygwtapp.com/index.html#user123
However the format is important to be like: http://myapp.com/user123
The 'something' in 'http://host/path#something' is a Fragment identifier. FIs have a specific feature: the page isn't reloaded if only FI part in URL changes, but they still take part in browser history.
FI's are a browser mechanism that GWT uses to create "pages", i.e. parts of GWT application that are bookmarkable and have history support.
You can try to use an URL without # (the FI separator), but then you will have a normal URL, that reloads the page with every change and it could not be (easily) a part of a normal GWT app.
mygwtapp.com/index.html#user123
That would be using the History mechanism (http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsHistory.html) which I would add is the recommended way of doing it.
However, if you insist on using something like http://myapp.com/user123, one of the possible ways is to have a servlet which accepts this request (you might have to switch to something like http://myapp.com/details?id=user123). The servlet will look up the DB and return your host html back. Before returning it will inject the required details as a Dictionary entry in the page (http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/i18n/client/Dictionary.html) On the client you can read this data and display on the UI
I have a website with 2 frames. Actions performed in 1 frame(enter data in text box/select radio button/click a href) cause the other frame to load data with javascript. I need to be able to enter data in the first frame and scrape the data in the second. What can I do for this?
Load the website in Firefox, then turn on the Firebug extension, enable the 'Net' tab, and have a look at the HTTP data being sent to and from the browser.
Sometimes it can help to try to forget what the webpage looks like, and concentrate on the posts and responses you see in Firebug's Net tab -- that's all you need to reproduce to get your data out.
You can either:
Reverse engineer the JS (monitoring HTTP traffic can help) to figure out what data actually gets sent to the server and then replicate that in your Perl.
Use WWW::Mechanize::Firefox to run a complete browser stack and interrogate it to read the results.