-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
58 lines (46 loc) · 2.13 KB
/
app.py
File metadata and controls
58 lines (46 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
from example.demo_ffmpeg import main
import asyncio
from threading import Thread
from flask import Flask, render_template
import jinja2.ext
####################################################################
# #
# SERVIDOR RTMP #
# #
def hls():
asyncio.run(main())
tHls = Thread(target=hls, args=[])
# #
# #
# #
####################################################################
####################################################################
# #
# SERVIDOR HTTP #
# #
flask = Flask(__name__, static_folder='lives', static_url_path='/streams', template_folder='templates')
# from pathlib import Path
# td = Path(__file__).parent.parent.parent / 'templates'
# sd = Path(__file__).parent.parent.parent / 'lives'
# flask = Flask(__name__, template_folder=td.resolve(), static_folder=sd.resolve(), static_url_path='/streams')
# print(sd.resolve())
# print(td.resolve())
# flask.config.from_pyfile
@flask.route('/play/<live>')
def home(live):
return render_template('player.html', live=live)
@flask.route('/')
def lista():
arquivos = list(map(lambda arquivo: arquivo.split('.'), os.listdir('lives')))
lista = []
for arquivo in arquivos:
if arquivo[1] == 'm3u8':
lista.append(arquivo[0])
return render_template('lista.html', lives=lista)
# #
# #
# #
####################################################################
tHls.start()
flask.run('0.0.0.0', debug=False)