Skip to content

Commit

Permalink
new app5 (fetch example) with fullscreen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Aug 17, 2018
1 parent f97ec75 commit 529cc0c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
13 changes: 7 additions & 6 deletions an_app5.py
@@ -1,16 +1,17 @@
# -*- coding: utf-8 -*-
import wuy
import wuy,re

# it's the future ... (call a http service during an async rpc method call)
# call a http service during an async rpc method call

class fetch(wuy.Window): # name the class as the web/<class_name>.html
size=(400,400)
size=wuy.FULLSCREEN

async def requestWeb(self,url):
return (await wuy.request(url)).content # use wuy.request(url,data=None,headers={})
async def feed(self):
r=(await wuy.request("https://www.reddit.com/r/pics/.rss")).content
return re.findall("https://i.redd.it/[^\.]+\....",r)

if __name__=="__main__":
fetch()
fetch() # CTRL-W or alt-f4 to quit !



Expand Down
23 changes: 16 additions & 7 deletions web/fetch.html
@@ -1,11 +1,20 @@
<script src="wuy.js"></script>
<style>
body,html,img {width:100%;height:100%;margin:0px;padding:0px}
</style>
<script>
function get(url) {
wuy.requestWeb(url) .then( txt=>{ document.getElementById("rep").innerHTML=txt; })
}
var list=[],N;

</script>
setTimeout(function() { //TODO: found a better way ;-)
wuy.feed().then( ll=>{
list=ll;
set(0)
})
},200)

<button onclick="get('https://pypi.org/project/wuy/')">Site 1</button>
<button onclick="get('https://pypi.org/project/reqman/')">Site 2</button>
<div id="rep"></div>
function set(n) {
N=n;
document.querySelector("#i").src=list[n];
}
</script>
<img id="i" src="" onclick="set( (N+1)%list.length)"/>

0 comments on commit 529cc0c

Please sign in to comment.