Spaces:
Running
Running
BraydenMoore
commited on
Commit
·
a4a02bf
1
Parent(s):
e04f6b7
Update main.py
Browse files
main.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from flask import Flask, Response, render_template, send_file, stream_with_context
|
2 |
import requests
|
3 |
import random
|
4 |
import pickle as pkl
|
@@ -32,9 +32,7 @@ def latlon_to_pixel(loc):
|
|
32 |
|
33 |
@app.route('/proxy/<path:url>')
|
34 |
def proxy(url):
|
35 |
-
|
36 |
print('URL:', url)
|
37 |
-
|
38 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
39 |
try:
|
40 |
req = requests.get(f'http://{url}', headers=headers, stream=True, timeout=20)
|
@@ -46,10 +44,13 @@ def proxy(url):
|
|
46 |
print(f'Error: {e}')
|
47 |
return send_file('static/error.png', mimetype='image/png')
|
48 |
|
49 |
-
|
50 |
@app.route('/')
|
51 |
def index():
|
52 |
-
|
|
|
|
|
|
|
|
|
53 |
#url = feed_dict[feed]['url']
|
54 |
url = live_urls[feed]
|
55 |
ip = ''.join(url.split('//')[-1]).split(':')[0]
|
|
|
1 |
+
from flask import Flask, Response, render_template, send_file, stream_with_context, session
|
2 |
import requests
|
3 |
import random
|
4 |
import pickle as pkl
|
|
|
32 |
|
33 |
@app.route('/proxy/<path:url>')
|
34 |
def proxy(url):
|
|
|
35 |
print('URL:', url)
|
|
|
36 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
37 |
try:
|
38 |
req = requests.get(f'http://{url}', headers=headers, stream=True, timeout=20)
|
|
|
44 |
print(f'Error: {e}')
|
45 |
return send_file('static/error.png', mimetype='image/png')
|
46 |
|
|
|
47 |
@app.route('/')
|
48 |
def index():
|
49 |
+
if 'current_feed' in session and request.args.get('new', 'false') == 'false':
|
50 |
+
feed = session['current_feed']
|
51 |
+
else:
|
52 |
+
feed = random.randint(0, len(live_urls) - 1)
|
53 |
+
session['current_feed'] = feed
|
54 |
#url = feed_dict[feed]['url']
|
55 |
url = live_urls[feed]
|
56 |
ip = ''.join(url.split('//')[-1]).split(':')[0]
|