-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
70 lines (45 loc) · 1.67 KB
/
Copy pathserver.py
File metadata and controls
70 lines (45 loc) · 1.67 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
63
64
65
66
67
68
69
70
import threading
from flask import Flask, render_template, redirect, url_for, request
from query import insert
from bot import start, new_request
application = Flask(__name__)
@application.route('/')
def main_page():
return render_template('index.html', title='PW Tech')
@application.route('/technology')
def technology():
return render_template('technology.html', title='Технология')
@application.route('/team')
def team():
return render_template('team.html', title='Команда')
@application.route('/projects')
def projects():
return render_template('projects.html', title='Проекты')
@application.route('/contact')
def contact():
return render_template('contact.html', title='Связаться с нами')
@application.route('/submit', methods=['POST'])
def submit_form():
if request.method == 'POST':
data = []
for list_type in request.form.keys():
list = request.form.getlist(list_type)
data.append(list[0])
id = insert(f"""INSERT INTO contacts (name, phone, city, company) VALUES ('{data[0]}', '{data[1]}', '{data[2]}', '{data[3]}')""")
new_request(id)
return redirect(url_for('main_page'))
@application.errorhandler(404)
def not_found_error(error):
return render_template('404.html', title='404'), 404
@application.errorhandler(500)
def internal_error(error):
return render_template('500.html', title='500'), 500
def start_server():
application.run(port=8080)
if __name__ == '__main__':
thread1 = threading.Thread(target=start_server)
thread2 = threading.Thread(target=start)
thread1.start()
thread2.start()
thread1.join()
thread2.join()