generated from neeltron/Flask-Starter-Kit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
68 lines (59 loc) · 1.61 KB
/
main.py
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
59
60
61
62
63
64
65
66
67
68
from flask import Flask, render_template, request
from replit import db
import random
def createLink(title):
if title == "index" or title == "":
print("you can't hack us, ha!")
else:
f = open("templates/" + title + ".html", "w")
code = """
<html>
<head>
<title>{}</title>
<link href="../static/styles.css" rel="stylesheet" type="text/css" />
<script src='https://meet.jit.si/external_api.js'></script>
</head>
<body>
<iframe allow="camera; microphone; display-capture" src = "https://meet.jit.si/{}" width = "1520" height = "680">
</iframe>
<a href = "https://quicksesh.co/"><button id = "submit3">Leave</button></a>
</body>
</html>
""".format(title, title)
f.write(code)
app = Flask(
__name__,
template_folder='templates',
static_folder='static'
)
# Index page and Rendering Basic Templates
@app.route('/', methods = ['GET', 'POST'])
def index():
if request.method == "POST":
id = random.randint(0, 1000)
title = request.form.get('title')
flag = 0
for i in db:
if db[i] == title:
flag = 1
if flag == 0:
db[str(id)] = title
print(db[str(id)])
createLink(title)
return render_template(db[str(id)] + '.html')
else:
createLink(title)
return render_template(title + '.html')
return render_template('index.html', obj = db)
@app.route('/join', methods = ['GET', 'POST'])
def join():
title = request.args.get('title')
if title != None:
return render_template(str(title)+'.html')
if __name__ == '__main__':
# Run the Flask app
app.run(
host='0.0.0.0',
debug=True,
port=8080
)