-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
77 lines (72 loc) · 2.12 KB
/
server.py
File metadata and controls
77 lines (72 loc) · 2.12 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
71
72
73
74
75
76
77
from flask import Flask, request, render_template, jsonify, url_for, redirect, g
import random
import json
# app = Flask(__name__)
# from .models import User
# from index import app, db
# from sqlalchemy.exc import IntegrityError
# from .utils.auth import generate_token, requires_auth, verify_token
app = Flask(__name__, static_folder="frontend/build/static", template_folder="frontend/build")
def get_hello():
greeting_list = ['Ciao', 'Hei', 'Salut', 'Hola', 'Hallo', 'Hej']
return random.choice(greeting_list)
@app.route('/', methods=['GET'])
def index():
return render_template('index.html')
@app.route("/check", methods=['POST'])
def check_user():
username = json.JSONDecoder(request.get_json())['username']
print(username)
return true
# @app.route('/<path:path>', methods=['GET'])
# def any_root_path(path):
# return render_template('index.html')
#
#
# @app.route("/api/user", methods=["GET"])
# @requires_auth
# def get_user():
# return jsonify(result=g.current_user)
#
#
# @app.route("/api/create_user", methods=["POST"])
# def create_user():
# incoming = request.get_json()
# user = User(
# email=incoming["email"],
# password=incoming["password"]
# )
# db.session.add(user)
#
# try:
# db.session.commit()
# except IntegrityError:
# return jsonify(message="User with that email already exists"), 409
#
# new_user = User.query.filter_by(email=incoming["email"]).first()
#
# return jsonify(
# id=user.id,
# token=generate_token(new_user)
# )
#
#
# @app.route("/api/get_token", methods=["POST"])
# def get_token():
# incoming = request.get_json()
# user = User.get_user_with_email_and_password(incoming["email"], incoming["password"])
# if user:
# return jsonify(token=generate_token(user))
#
# return jsonify(error=True), 403
#
#
# @app.route("/api/is_token_valid", methods=["POST"])
# def is_token_valid():
# incoming = request.get_json()
# is_valid = verify_token(incoming["token"])
#
# if is_valid:
# return jsonify(token_is_valid=True)
# else:
# return jsonify(token_is_valid=False), 403