-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (46 loc) · 2.29 KB
/
Copy pathmain.py
File metadata and controls
62 lines (46 loc) · 2.29 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
59
60
61
62
from flask import Flask, render_template, request
from discord_webhook import DiscordWebhook, DiscordEmbed
webhook_url = "your url"
app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
def home():
if request.method == "POST": #on form submission
username = request.form["username"]
age = request.form["age"]
country = request.form["country"]
play = request.form["play"] #how often are you likely to play?
join = request.form["join"] #why would you like to join?
fav = request.form["fav"] #favourite aspect of Minecraft?
discord = request.form["discord"] #do you use Discord a lot?
mature = request.form["mature"]
smp = request.form["smp"] #previous smp(s)
time = request.form["time"] #how long have you been playing Minecraft
guidelines = request.form["guidelines"]
if guidelines == "on":
guidelines = "Yes"
else:
guidelines = "No"
webhook = DiscordWebhook(url=webhook_url)
# create embed object for webhook
embed = DiscordEmbed(title='Form Submission', color='03b2f8')
# set timestamp (default is now)
embed.set_timestamp()
# add fields to embed
embed.add_embed_field(name='Username', value=username)
embed.add_embed_field(name='Age', value=age)
embed.add_embed_field(name='Location', value=country)
embed.add_embed_field(name='How often they play', value=play)
embed.add_embed_field(name='Why they want to join', value=join, inline=False)
embed.add_embed_field(name='Favourite aspect of Minecraft', value=fav, inline=False)
embed.add_embed_field(name='Discord usage', value=discord)
embed.add_embed_field(name='Are they mature?', value=mature)
embed.add_embed_field(name='Previous Smp', value=smp, inline=False)
embed.add_embed_field(name='How long they have played', value=time)
embed.add_embed_field(name='Read and accepted Guidelines', value=guidelines)
# add embed object to webhook
webhook.add_embed(embed)
response = webhook.execute()
return render_template("success.html")
else:
return render_template("form.html")
app.run(host='0.0.0.0', port=81)