Beispiel #1
0
def register_api(view, endpoint, url, pk='id', pk_type='int'):
    view_func = view.as_view(endpoint)
    app.add_url_rule(url,
                     view_func=view_func,
                     defaults={pk: None},
                     methods=[
                         'GET',
                     ])
    app.add_url_rule(url, view_func=view_func, methods=[
        'POST',
    ])
    app.add_url_rule('%s<%s:%s>' % (url, pk_type, pk),
                     view_func=view_func,
                     methods=['GET', 'PUT', 'DELETE'])
Beispiel #2
0
        return jsonify(access_token=access_token,
                       logged_in_as=user.email,
                       name=user.name)
        # return jsonify({
        #     'result': {'access_token': access_token,
        #                'refresh_token': refresh_token,
        #                'logged_in_as': f"{user.email}"},
        #     'name': f"{user.name}"
        # })
    except DoesNotExist:
        print("USER NOT FOUND")
        return jsonify(error="USER NOT FOUND"), 500


# rotas de usuario
app.add_url_rule('/users', view_func=UserController.index, methods=['GET'])
app.add_url_rule('/users', view_func=UserController.store, methods=['POST'])
app.add_url_rule('/users/<id>', view_func=UserController.show, methods=['GET'])
app.add_url_rule('/users/me',
                 view_func=UserController.loggedUser,
                 methods=['GET'])
app.add_url_rule('/users/update',
                 view_func=UserController.update,
                 methods=['PUT'])
app.add_url_rule('/users/<id>',
                 view_func=UserController.destroy,
                 methods=['DELETE'])
app.add_url_rule('/users/disciplinas',
                 view_func=UserController.update_disciplinas,
                 methods=['PATCH'])
Beispiel #3
0
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS

@artist.route('/artist/<artistid>/file', methods=['POST'])
def upload_file(artistid):
    if request.method == 'POST':
        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER_ARTIST'], filename))
            filepath = UPLOAD_FOLDER + filename
        g.database.execute("""UPDATE MuShMe.artists SET Artist_pic="%s" WHERE Artist_id="%s" """ % (filepath, artistid))
        g.conn.commit()
        return redirect(url_for('artist.artistPage', artistid=artistid))

app.add_url_rule('/artist/uploads/<filename>', 'uploaded_file',build_only=True)
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {'/artist/uploads':  'src/static/' + app.config['UPLOAD_FOLDER_ARTIST']   })

@artist.route('/artist/<artistid>/edit',methods= ['POST'])
def editArtist(artistid):
    if request.method == 'POST':
        print request.form
        if request.form['editname'] != '':
            g.database.execute("""UPDATE MuShMe.artists SET Artist_name=%s WHERE Artist_id=%s """, ([request.form['editname']], artistid))
            g.conn.commit()
        
        if request.form['begin_year'] != '0' and request.form['begin_month'] != '0' and request.form['begin_day'] != '0':
            g.database.execute("""UPDATE MuShMe.artists SET Begin_date_year="%s" WHERE Artist_id="%s" """ % 
                (request.form['begin_year'], artistid))
            g.conn.commit()
Beispiel #4
0
import dataStruct as _ds
from model import db as _db
from model import updateOrInsertToTable

import math
import os
import datetime
import pytz
import urllib2
import json
from urllib import unquote
import timeUtils as _timeUtils
from datetime import datetime as _datetime

app.add_url_rule('/',
                 view_func=_views.Index.as_view('index',
                                                template_name="index.html"))
app.add_url_rule('/newmsg',
                 view_func=_views.Messaging.as_view(
                     'newmsg', template_name="index.html"))


@app.route("/citydatetime", methods=["POST"])
def getCityDateTime():
    data = request.get_json()

    if not data:
        return jsonify({"status": "No data to process."}), 201

    tz = data.get("tz")
    time, date = _utils.getCityDateTime(tz)
Beispiel #5
0
from src import app

import src.controller.user as user
import src.controller.group as group
import src.auth as auth

# User
app.add_url_rule('/users/<string:id>', 'user-get', user.get, methods=['GET'])
app.add_url_rule('/users', 'user-insert', user.insert, methods=['POST'])
app.add_url_rule('/users', 'user-update', user.update, methods=['PUT'])
app.add_url_rule('/users/<string:id>/groups',
                 'user-groups-get',
                 user.groups,
                 methods=['GET'])

# Login
app.add_url_rule('/login', 'login', auth.login, methods=['POST'])

# Grouups
app.add_url_rule('/groups/<string:id>',
                 'group-get',
                 group.get,
                 methods=['GET'])
app.add_url_rule('/groups', 'group-insert', group.insert, methods=['POST'])
app.add_url_rule('/groups-test', 'group-test', group.test, methods=['POST'])
app.add_url_rule('/groups',
                 'group-get-by-user',
                 group.user_groups,
                 methods=['GET'])
app.add_url_rule('/groups/<string:group_id>/add/<string:user_id>',
                 'group-add-user',
Beispiel #6
0
from src import app
from src.resources.smoke import Smoke
from src.resources.actors import ActorListApi
from src.resources.films import FilmListApi
from src.resources.populate_db import PopulateDB, PopulateDBThreaded, PopulateDBThreadPoolExecutor
from src.resources.aggregations import AggregationApi
from src.resources.auth import AuthLogin, AuthRegister

smoke_api = Smoke.as_view('smoke')
app.add_url_rule('/smoke', view_func=smoke_api, strict_slashes=False)

film_list_api = FilmListApi.as_view('films')
app.add_url_rule('/films', view_func=film_list_api, strict_slashes=False)
app.add_url_rule('/films/<uuid>',
                 view_func=film_list_api,
                 strict_slashes=False)

populate_db = PopulateDB.as_view('populate')
app.add_url_rule('/populate_db', view_func=populate_db, strict_slashes=False)

populate_db_threaded = PopulateDBThreaded.as_view('popultae_with_threads')
app.add_url_rule('/populate_db_threaded',
                 view_func=populate_db_threaded,
                 strict_slashes=False)

populate_db_executor = PopulateDBThreadPoolExecutor.as_view(
    'popultae_with_executor')
app.add_url_rule('/populate_db_executor',
                 view_func=populate_db_executor,
                 strict_slashes=False)
Beispiel #7
0
#   We are only doing part of what is on this page. We are creating
#   a centralized URL map in this file and one of the functions is a
#   warmup function that loads the views into a new instance when google
#   app engine has to start up a new instance due to load increases. The example
#   on this url shows how to load in the view functions one at a time as needed.
#   Loading in one at a time will cause decorator problems, so to make things
#   easier, we are doing it like this.
#
# Warmup info: http://stackoverflow.com/questions/8235716/how-does-the-warmup-service-work-in-python-google-app-engine

from flask import Flask
from src import app, views, api
from views import render_response

# Warmup
app.add_url_rule('/_ah/warmup',view_func=views.warmup)

################################ Website landing pages ##################################
# Home page
app.add_url_rule('/',view_func=views.index,methods=["GET","POST"])

# Waitlist Manager (Info)
app.add_url_rule('/waitlist-manager',view_func=views.waitlist_manager,methods=['GET','POST'])

# Settings
app.add_url_rule('/settings',view_func=views.settings,methods=["GET","POST"])

# Login
app.add_url_rule('/login',view_func=views.login,methods=["GET","POST"])

# Join
Beispiel #8
0
# Lazy loading Info: http://flask.pocoo.org/docs/patterns/lazyloading/
#   We are only doing part of what is on this page. We are creating
#   a centralized URL map in this file and one of the functions is a
#   warmup function that loads the views into a new instance when google
#   app engine has to start up a new instance due to load increases. The example
#   on this url shows how to load in the view functions one at a time as needed.
#   Loading in one at a time will cause decorator problems, so to make things
#   easier, we are doing it like this.
#
# Warmup info: http://stackoverflow.com/questions/8235716/how-does-the-warmup-service-work-in-python-google-app-engine

from src import app, views
from views import render_response

# Warmup
app.add_url_rule('/_ah/warmup',view_func=views.warmup)

################################ Website landing pages ##################################
# Home page
app.add_url_rule('/',view_func=views.index)

# Library
app.add_url_rule('/library',view_func=views.library)

# Network
app.add_url_rule('/network',view_func=views.network)

# Discover
app.add_url_rule('/discover',view_func=views.discover)

# Search