Commit fcc8a558 authored by Willard's avatar Willard

Start adding endpoints for Android client API

parent 56e7f00e
...@@ -3,6 +3,7 @@ from flask import Flask ...@@ -3,6 +3,7 @@ from flask import Flask
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate from flask_migrate import Migrate
from flask_login import LoginManager from flask_login import LoginManager
from flask_httpauth import HTTPAuth
app = Flask(__name__) app = Flask(__name__)
app.config.from_object('canteeneo.config.BaseConfig') app.config.from_object('canteeneo.config.BaseConfig')
...@@ -10,6 +11,8 @@ app.config.from_object('canteeneo.config.BaseConfig') ...@@ -10,6 +11,8 @@ app.config.from_object('canteeneo.config.BaseConfig')
login_manager = LoginManager() login_manager = LoginManager()
login_manager.init_app(app) login_manager.init_app(app)
auth = HTTPBasicAuth()
db = SQLAlchemy(app) db = SQLAlchemy(app)
migrate = Migrate(app, db) migrate = Migrate(app, db)
......
from canteeneo import app from canteeneo import app, db
from flask import jsonify, request from flask import jsonify, request
from models import Dish, Stall, Location from models import Dish, Stall, Location, User
from datetime import datetime from datetime import datetime
@app.route('/api/all') @app.route('/api/all')
...@@ -41,3 +41,31 @@ def search(): ...@@ -41,3 +41,31 @@ def search():
'image_path': dish.image_path 'image_path': dish.image_path
}) })
return jsonify(data) return jsonify(data)
@app.route('/api/users/new', methods=["POST"])
def new_user():
name = request.form['name']
email = request.form['email']
password = request.form['password']
user = User.query.filter_by(name=name).first()
if user is not None:
return 'Username is alreadye taken!'
user = User.query.filter_by(email=email).first()
if user is not None:
return 'Email address is already taken!'
user = User(name, email, password)
db.session.add(user)
db.session.commit()
return 'User account successfully created!'
@auth.verify_password
def verify_password(username, password):
pass
@app.route('/api/token')
@auth.login_required
def get_auth_token():
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment