-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflask_server.py
57 lines (42 loc) · 1.34 KB
/
flask_server.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
#!flask/bin/python
"""
Project assessment
Data Representation Module GMIT 2020
Submitted by: Olga Rozhdestvina (Student No: G00387844)
Lecturer: Andrew Beatty
"""
# MAIN FLASK SERVER.
from flask import Flask, render_template
from werkzeug.exceptions import BadRequest, NotFound, MethodNotAllowed, InternalServerError
# Importing blueprints.
from dentists.dentists import dentist_table
from patients.patients import patient_table
from login.login import log
# Flask app.
app = Flask(__name__, static_folder="main/static",
template_folder="main/templates")
# Secret key to login.
app.secret_key = 'someKey'
# Regestering blueprints.
app.register_blueprint(dentist_table, url_prefix="/dentists/")
app.register_blueprint(patient_table, url_prefix="/patients/")
app.register_blueprint(log, url_prefix="/#")
# Main page.
@app.route('/')
def home():
return render_template("index.html")
# Error handlers.
@app.errorhandler(BadRequest)
def handle_bad_request(e):
return 'Bad request!', 400
@app.errorhandler(NotFound)
def handle_bad_request(e):
return 'Page is not found!', 404
@app.errorhandler(MethodNotAllowed)
def handle_bad_request(e):
return 'Method is not allowed!', 405
@app.errorhandler(InternalServerError)
def handle_bad_request(e):
return 'Internal server error!', 500
if __name__ == '__main__':
app.run(debug=True)