A little request
i have this:
import asyncio
import repltalk
import time
import os
# audio.play_file('tarzan-screaming.wav')
client = repltalk.Client()
async def main():
current_message = ""
top_posts = await client.boards.all.get_posts(sort="new")
last_post = top_posts[0]
while True:
top_posts = await client.boards.all.get_posts(sort="new")
last_post = top_posts[0]
os.system("clear")
current_message = ""
current_message += ("POST NAME:\n")
current_message += (last_post.title +"\n------------------\nAUTHOR:\n")
current_message += (str(last_post.author) +"\n------------------\n")
current_message += ("URL:\n" + last_post.url + "\n------------------")
print(current_message)
current_post = top_posts[0]
if current_post.title != last_post.title:
# audio.play_file('tarzan-screaming.wav')
os.system("clear")
current_message = ""
current_message + ("----------\nNEW POST!!!\n----------\nPOST NAME:\n")
current_message + (current_post.title +"------------------\nAUTHOR:\n")
current_message + (str(current_post.author) +"\n------------------\n")
current_message + ("URL:\n" + last_post.url + "\n------------------")
print(current_message)
last_post = current_post
time.sleep(4)
print("Updating...")
time.sleep(1)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
It notifies me when there's a new post on the repl talk.
I want to make it a Django web app (flask is ok too)
but it's in an async function, I don't want any functions, I don't really want any async stuff happening.
all I need is someone to rewrite this (or teach me how to do it) so its not in a function.
Voters
when you are dealing with django or flask, everything is related to functions. You need to deal with functions. So you can just use your code in. Functions are necessary
@RYANTADIPARTHI Ok
@ch1ck3n np.
@RYANTADIPARTHI done
@ch1ck3n thanks!
@RYANTADIPARTHI uses lambda to make views