Python Forum
Web App That Request Data from Another Web Site every 12-hours
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web App That Request Data from Another Web Site every 12-hours
#8
(Sep-24-2018, 03:12 AM)snippsat Wrote: It don't have to be called in route,it work independent of that. It's was just a demo to also send values from schedule function to client with jinja.
from flask import Flask, render_template, jsonify from apscheduler.schedulers.background import BackgroundScheduler import random import requests app = Flask(__name__) def parse_func(): response = requests.get('https://nghttp2.org/httpbin/get') r = response.json() lst = [r['url'], r['origin']] rand_value = random.choice(lst) print(rand_value) #return(rand_value) @app.route("/") def template(): return render_template('sh2.html') if __name__ == '__main__': scheduler = BackgroundScheduler() scheduler.add_job(parse_func, 'interval', seconds=15) scheduler.start() app.run(debug=True)
See that it run schedule interval,and routes can to there thing not knowing about this at all.
Thank you. Now it is more clear, but I want to display this printed value through a route without sending request every time the route called. I am really appreciate for you effort. I know, I am asking lots of questions, but I am beginner and in fact I cannot find a solution for this problem. Wall
Reply


Messages In This Thread
RE: Web App That Request Data from Another Web Site every 12-hours - by jomonetta - Sep-24-2018, 03:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to scraping data from dinamic site sergio21124444 2 781 Nov-08-2023, 12:43 PM
Last Post: sergio21124444
  POST request with form data issue web scraping hoff1022 1 2,742 Aug-14-2020, 10:25 AM
Last Post: kashcode
  Scraping a dynamic data-table in python through AJAX request filozofo 1 3,936 Aug-14-2020, 10:13 AM
Last Post: kashcode
  How to retrieve data from site ROHK 2 2,491 Mar-01-2019, 12:26 PM
Last Post: ROHK
  Mechanize and BeautifulSoup read not correct hours vaeVictis 5 4,522 Jan-15-2019, 01:27 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020