Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS123-Canteeneo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Willard Torres
CS123-Canteeneo
Commits
fcc8a558
Commit
fcc8a558
authored
Oct 24, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start adding endpoints for Android client API
parent
56e7f00e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
__init__.py
canteeneo/__init__.py
+3
-0
api.py
canteeneo/api.py
+31
-3
No files found.
canteeneo/__init__.py
View file @
fcc8a558
...
...
@@ -3,6 +3,7 @@ from flask import Flask
from
flask_sqlalchemy
import
SQLAlchemy
from
flask_migrate
import
Migrate
from
flask_login
import
LoginManager
from
flask_httpauth
import
HTTPAuth
app
=
Flask
(
__name__
)
app
.
config
.
from_object
(
'canteeneo.config.BaseConfig'
)
...
...
@@ -10,6 +11,8 @@ app.config.from_object('canteeneo.config.BaseConfig')
login_manager
=
LoginManager
()
login_manager
.
init_app
(
app
)
auth
=
HTTPBasicAuth
()
db
=
SQLAlchemy
(
app
)
migrate
=
Migrate
(
app
,
db
)
...
...
canteeneo/api.py
View file @
fcc8a558
from
canteeneo
import
app
from
canteeneo
import
app
,
db
from
flask
import
jsonify
,
request
from
models
import
Dish
,
Stall
,
Location
from
models
import
Dish
,
Stall
,
Location
,
User
from
datetime
import
datetime
@
app
.
route
(
'/api/all'
)
...
...
@@ -41,3 +41,31 @@ def search():
'image_path'
:
dish
.
image_path
})
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment