-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
46 lines (39 loc) · 1.28 KB
/
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
from flask import Flask, request, render_template, jsonify
from flask_restful import Api, marshal
from flask_cors import CORS
from settings import *
from waitress import serve
import time
import threading
app = Flask(__name__, template_folder='templates')
api = Api(app)
CORS(app)
from app.view import *
from app.errors import *
from app.find_users import *
from app.local_db import *
def check_new_user():
while True:
main()
time.sleep(TIME_TO_CHECK_DOMAIN)
if __name__ == "__main__":
@app.errorhandler(ApiBaseError)
@app.errorhandler(UsernameNotFound)
@app.errorhandler(UserNotExist)
@app.errorhandler(Unauthorized)
@app.errorhandler(SqlErrorNewUserError)
@app.errorhandler(FileError)
@app.errorhandler(PermissionFolderError)
@app.errorhandler(PasswordError)
@app.errorhandler(RemoveFolderError)
@app.errorhandler(SqlErrorDropDatabase)
@app.errorhandler(SqlErrorPermissionDB)
@app.errorhandler(SqlErrorUploadDB)
@app.errorhandler(CredentialMissing)
def handle_error(error):
return error.to_dict(), getattr(error, "http_code")
add_exist_users_to_db()
x = threading.Thread(target=check_new_user)
x.start()
app.config['TEMPLATES_AUTO_RELOAD'] = True
serve(app, host=IP, port=PORT, threads=2)