Beispiel #1
0
    def add_output_size(self):
        self.base_link += 'outputsize=' + self.output_size.value + '&'
        return self

    def add_keywords(self):
        self.base_link += 'keywords=' + self.keywords + '&'
        return self

    def add_time_period(self):
        self.base_link += 'time_period=' + self.time_period + '&'
        return self

    def add_series_type(self):
        self.series_type += 'series_type=' + self.series_type.value + '&'
        return self

    def get_link(self):
        return self.base_link + 'apikey=' + self.api_key


api.add_resource(UserLogin, '/login')
api.add_resource(UserRegister, '/register')
api.add_resource(StockData, '/stockdata')

if __name__ == '__main__':
    # endpoint = AlphaVantageEndpoint(keywords="FAA", time_period="50")
    # endpoint = endpoint.add_function_to_link().add_symbol_to_link().add_output_size().add_interval_to_link().get_link()
    # response = json.loads(urllib.request.urlopen(endpoint).read().decode("utf-8").replace("'", '"'))
    # print(response)
    app.run()
Beispiel #2
0
@app.route('/')
def index():
    return jsonify({'message': 'Hello, World!'})


@app.before_first_request
def create_tables():
    db_path = app.config['SQLALCHEMY_DATABASE_URI']
    if os.path.exists(db_path):
        os.unlink(app.config['SQLALCHEMY_DATABASE_URI'])
    db.create_all()
    populate_example_data()


def populate_example_data():
    example_users = [('hermione', 'granger'), ('ron', 'weasley'),
                     ('nevil', 'longbottom')]
    for username, password in example_users:
        new_user = UserModel(username=username,
                             password=UserModel.generate_hash(password))
        try:
            new_user.save_to_db()
        except:
            return


api.add_resource(resources.UserLogin, '/login')
api.add_resource(resources.TokenRefresh, '/token/refresh')
api.add_resource(resources.JsonPatch, '/jsonpatch')
api.add_resource(resources.Thumbnail, '/thumbnail')
Beispiel #3
0
from config import app, api
from auth import Register, Login, Logout
from views import SecretResource

api.add_resource(Register, "/register")
api.add_resource(Login, "/login")
api.add_resource(Logout, "/logout")
api.add_resource(SecretResource, "/secret")
Beispiel #4
0
from config import api
from resources.calc_cargo_resource import CalcCargo

api.add_resource(CalcCargo, '/', '/api/calc_cargo')
Beispiel #5
0
                try:
                    db.session.commit()
                    return todo_schema.dump(up_todo)
                    #title = "Update ToDo Data"
                    #return render_template('update.html', title=title, ToDo=up_todo)
                except:
                    return jsonify(
                        {"result": "There was a problem updating ToDo data."})
            else:
                return jsonify({
                    'result':
                    "Please add proper FORMAT [YYYY-MM-DD] of Target Date for your Updated ToDo."
                })


##For GET all / POST Method
api.add_resource(TodoResource, '/', '/api/todo/')

##For PUT Method (UPDATE) / GET / DELETE
api.add_resource(TodolistResource, '/api/todo/<int:id>',
                 '/api/update/<int:id>', '/api/delete/<int:id>')


##
def init_db():
    db.create_all()


if __name__ == '__main__':
    init_db()  # First time , it'll create all Tables
    app.run(debug=True)
Beispiel #6
0
from config import api, app
import constant
import os
from api.AppConfig import ApplicationConfiguration
from api.Images import Images
from api.Flavors import Flavors

api.add_resource(ApplicationConfiguration,
                 '/api/azure/application-configuration')
api.add_resource(Images, '/api/azure/images')
api.add_resource(Flavors, '/api/azure/flavors')

if __name__ == '__main__':
    ENVIRONMENT_DEBUG = os.environ.get(constant.APP_DEBUG, True)
    ENVIRONMENT_HOST = os.environ.get(constant.APP_HOST, '0.0.0.0')
    ENVIRONMENT_PORT = os.environ.get(constant.APP_PORT, '5012')
    app.run(debug=ENVIRONMENT_DEBUG,
            host=ENVIRONMENT_HOST,
            port=ENVIRONMENT_PORT)
Beispiel #7
0
from controllers.votecard_scan.voterfrontside import Votefront
from controllers.aadhar_scan.post_aadhar import ScanAadhar
from controllers.passport.imagepost import PostImageDetail
from flask import Flask, make_response, request
import config
from config import app, cur_dir, api, main
import os
import pathlib
from flask_cors import CORS

CORS(app, resources={r"/api/*": {"origins": "*"}})

app.secret_key = b'_5#y2L"F4Q8z\n\xec]/'
""" call for passport and visa"""

api.add_resource(PostImageDetail, '/api/postimagedetail')
""" call for aadhar card for front and back side"""

api.add_resource(ScanAadhar, '/api/scan_aadhar')
""" call for voterid scan for front and backside"""

api.add_resource(Votefront, '/api/voterscan')
""" call for pan card """

api.add_resource(PanCardDetail, '/api/panscan')
""" call for driving scan"""

api.add_resource(drivingScan, '/api/scandriving')

if __name__ == "__main__":
    main()
Beispiel #8
0
""" Weather API that give some information about current weather. """

from config import app, api
from resources.register import Register
from resources.refill import Refill
from resources.weather import Weather

api.add_resource(Register, "/register")
api.add_resource(Weather, "/weather")
api.add_resource(Refill, "/refill")

if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0")
Beispiel #9
0
from config import api, db, app
import views
import models
import resources
from flask import session


@app.before_first_request
def create_tables():
    db.create_all()


api.add_resource(resources.Follows, '/follows')
#api.add_resource(resources.ReceiverDataByCurp, '/Curps/<curp>')
api.add_resource(resources.ReceiverDataById, '/receiver/<id>')
api.add_resource(resources.ReceiverDataByCurpGuest, '/CurpsGuest/<curp>')
api.add_resource(resources.ReceiverData,
                 '/searchReceiver/<method>/<search_data>')
api.add_resource(resources.ReceiversByEvent, '/receiversByEvent/<event_id>')
api.add_resource(resources.CreateUser, '/createUser')
api.add_resource(resources.DeleteUser, '/deleteUser/<id_user>')
api.add_resource(resources.EditUser, '/editUser/<id_user>')
api.add_resource(resources.CreateReceiver, '/createReceiver')
api.add_resource(resources.DeleteReceiver, '/deleteReceiver')
api.add_resource(resources.EditReceiver, '/editReceiver/<id_receiver>')
api.add_resource(resources.CreateReceiverMirror, '/createReceiverMirror')
api.add_resource(resources.ApproveReceiverModification,
                 '/approveReceiverModification/<id_receiver>')
api.add_resource(resources.CancelReceiverModification,
                 '/cancelReceiverModification/<id_receiver>')
api.add_resource(resources.FollowUpdate, '/followUpdate/<id_follow>')
Beispiel #10
0
from config import api
from .resorurceDictionary import get_add_Words, get_delete_update_Word, update
'''Endpoints'''
api.add_resource(get_add_Words, '/restwords')
api.add_resource(get_delete_update_Word, '/restwords/<idWord>')
api.add_resource(update, '/restwordsUpdate')
Beispiel #11
0
from config import app, api, logger

from resources.Plants import Tomato_Prediction,Apple_Prediction,Cherry_Prediction,Corn_Prediction,Grape_Prediction,Peach_Prediction,Pepper_Prediction,Potato_Prediction,Strawberry_Prediction,Tomato_Prediction

"""
    Routing
"""

api.add_resource(Apple_Prediction, '/api/Apple_Prediction', endpoint='Apple_Prediction')
api.add_resource(Cherry_Prediction, '/api/Cherry_Prediction', endpoint='Cherry_Prediction')
api.add_resource(Corn_Prediction, '/api/Corn_Prediction', endpoint='Corn_Prediction')
api.add_resource(Grape_Prediction, '/api/Grape_Prediction', endpoint='Grape_Prediction')
api.add_resource(Peach_Prediction, '/api/Peach_Prediction', endpoint='Peach_Prediction')
api.add_resource(Pepper_Prediction, '/api/Pepper_Prediction', endpoint='Pepper_Prediction')
api.add_resource(Potato_Prediction, '/api/Cherry_Prediction', endpoint='Potato_Prediction')
api.add_resource(Strawberry_Prediction, '/api/Strawberry_Prediction', endpoint='Strawberry_Prediction')
api.add_resource(Tomato_Prediction, '/api/Tomato_Prediction', endpoint='Tomato_Prediction')





if __name__ == "__main__":
    app.run(debug=True)
Beispiel #12
0
from config import app, api
from auth import Register, Login, Logout
from views import (GetUserDetails)
from flask import send_from_directory

api.add_resource(Register, "/register")
api.add_resource(Login, "/login")
api.add_resource(GetUserDetails, "/get-user-details")
api.add_resource(Logout, "/logout")


@app.route('/assets/<path:path>')
def serve_files(path):
    return send_from_directory('templates/assets/', path)


@app.route("/")
def index():
    return {"status": "server is up and running"}
from config import api, app
from views import index, Search

# index() Route
app.add_url_rule("/", 'index', index, methods=['GET'])

# search() Route
api.add_resource(Search, "/search")
Beispiel #14
0
from flask import Flask, jsonify
from flask_restful import Api
from resources.forecast import Forecast, ForecastAnalyze
from db.database import create_database
from flask_sqlalchemy import SQLAlchemy
from config import app, api, db, db_rel_path

api.add_resource(Forecast, '/cidade')
api.add_resource(ForecastAnalyze, '/analise')

if __name__ == '__main__':
    #db.create_all()
    create_database(db_rel_path)
    app.run()
Beispiel #15
0
from config import api
from resources.vsm_resource import VSMResource

api.add_resource(VSMResource, '/api/vsn/<string:vsn>')
Beispiel #16
0
    def delete(self, dev_id):
        device = current_identity.devices().find(dev_id)
        if device is None:
            response = jsonify({"message": "Device not found"})
            response.status_code = 404
            return response

        client.publish(device.topic, "%d" % -1, qos=2)
        device.delete()

        response = jsonify({"message": "Device deleted successfully"})
        response.status_code = 200
        return response


api.add_resource(Devices, '/dev', '/dev/<int:dev_id>')


@api.resource('/passreset')
class PasswReset(Resource):
    def __init__(self):
        self.post_parser = reqparse.RequestParser(bundle_errors=True)
        self.post_parser.add_argument('email', type=str, help='email', required=True)

        self.serializer = URLSafeSerializer(app.config['SECRET_KEY'])

        self.put_parser = reqparse.RequestParser(bundle_errors=True)
        self.put_parser.add_argument('password', type=str, help='password', required=True)
        self.put_parser.add_argument('token', type=str, help='token', required=True)

    def encode_token(self, user):
Beispiel #17
0
from config import app, api
from res.UserRes import UserResource as User

api.add_resource(User, '/users/<int:user_id>')


@app.errorhandler(404)
def page_not_found(e):
    return "<h1>404</h1><p>The resource could not be found.</p>", 404


if __name__ == "__main__":
    app.run(host="0.0.0.0", port="5000", debug=True)
Beispiel #18
0
from resources.Register import Register
from resources.Login import Login
from resources.UserExists import UserExists
from resources.ClassifyEmotion import ClassifyEmotion
from resources.ResetPassword import ResetPassword
from resources.UserInfo import UserInfo
from resources.PhotoDescription import PhotoDescription
from resources.EmotionsQuery import EmotionsQuery
from resources.PhotoUri import PhotoUri
from resources.PhotoTag import PhotoTag
from resources.AdminQuery import AdminQuery
from resources.AdminQuery2 import AdminQuery2
from resources.EditEmotions import EditEmotions
from resources.IsAdmin import IsAdmin

api.add_resource(Register, '/Register')
api.add_resource(UserExists, '/UserExists')
api.add_resource(Login, '/Login')
api.add_resource(ClassifyEmotion, '/ClassifyEmotion')
api.add_resource(ResetPassword, '/ResetPassword')
api.add_resource(UserInfo, '/UserInfo')
api.add_resource(PhotoDescription, '/PhotoDescription')
api.add_resource(EmotionsQuery, '/EmotionsQuery')
api.add_resource(PhotoTag, '/PhotoTag')
api.add_resource(PhotoUri, '/PhotoUri')
api.add_resource(AdminQuery, '/AdminQuery')
api.add_resource(AdminQuery2, '/SplAdminQuery')
api.add_resource(EditEmotions, '/EditEmotions')
api.add_resource(IsAdmin, '/IsAdmin')

Beispiel #19
0
from resources.user import (UserLogin, UserRegister, UserLogout, TokenRefresh,
                            User, PasswordConfirmation, ConfirmPasswordAction,
                            AvatarUpload)
from resources.vendor import (VendorRegister, VendorLogin, VendorLogout,
                              AccountInfo, PendingApproval, VendorInfo,
                              VendorList)
from resources.picture import (Picture, PictureAction, PictureByCreator,
                               PictrueByArtist)

from resources.comment import Comment, CommentCreation, Comment1
from resources.reply import Reply, ReplyCreation
from resources.confirmation import ResendEmailConfirmationToken, EmailConfirmation
from resources.notification import Notification, ReplyNotification

# add routes to API
api.add_resource(UserRegister, '/user/register')
api.add_resource(UserLogin, '/user/login')
api.add_resource(TokenRefresh, '/user/authenticate')
api.add_resource(UserLogout, '/user/logout')
api.add_resource(EmailConfirmation, '/user/register')
api.add_resource(AvatarUpload, '/user/avatar/upload')
api.add_resource(PasswordConfirmation, '/authenticate')
api.add_resource(ConfirmPasswordAction, '/user/confirm/<string:token>')
api.add_resource(User, '/user')

api.add_resource(VendorLogin, '/vendor/login')
api.add_resource(VendorLogout, '/vendor/logout')
api.add_resource(VendorRegister, '/vendor/register')
api.add_resource(VendorInfo, '/vendor/information')
api.add_resource(VendorList, '/vendor/list/<string:_id>')
Beispiel #20
0
import os
from config import app, api
from api.Pipeline import Pipeline

api.add_resource(Pipeline, '/api/pipeline')

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=5003, debug=True)
Beispiel #21
0
from controllers.User import UserController
from controllers.Login import LoginController
from controllers.Register import RegisterController
from config import api

api.add_resource(RegisterController, '/register', '/register/<string:phone>/<string:code>')
api.add_resource(UserController, '/users', '/users/<string:id>')
api.add_resource(LoginController, '/login')
# noinspection PyUnresolvedReferences
from config import api, app, db
from resources.HelloWorld import HelloWorld
from resources.users import Users
from resources.sellers import Sellers

api.add_resource(HelloWorld, '/')
api.add_resource(Users, '/v1/users')
api.add_resource(Sellers, '/v1/sellers')
Beispiel #23
0
from http import HTTPStatus
from config import api, app
from resources.register import Register
from resources.login import Login
from resources.password_change import PasswordChange
from resources.username_change import UsernameChange
from resources.refill import Refill
from resources.update_balance import UpdateBalance
from resources.check_balance import CheckBalance
from resources.transfer import Transfer
from resources.take_loan import TakeLoan
from resources.pay_loan import PayLoan

api.add_resource(Register, "/register")
api.add_resource(Login, "/login")
api.add_resource(PasswordChange, "/passwordchange")
api.add_resource(UsernameChange, "/usernamechange")
api.add_resource(Refill, "/refill")
api.add_resource(UpdateBalance, "/updatebalance")
api.add_resource(CheckBalance, "/checkbalance")
api.add_resource(Transfer, "/transfer")
api.add_resource(TakeLoan, "/takeloan")
api.add_resource(PayLoan, "/payloan")

if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0")
Beispiel #24
0
from api.v1.scraping import ScrapingAPI
from flask_restful import Resource
from config import app, api

api_route = '/api/v1'

app.config.update(DEBUG=True,
                  WEBPACKEXT_MANIFEST_PATH='/app/webkit-build/manifest.json')


class HelloWorld(Resource):
    def get(self):
        return {'hello': 'world'}


api.add_resource(CategoryAPI, api_route + '/categories')
api.add_resource(BooksAPI, api_route + '/books/<int:id>')
api.add_resource(ScrapingAPI, api_route + '/scraping')


@app.route('/dist/<path:path>')
def send_js(path):
    return send_from_directory('webkit-build', path)


#
#
@app.route('/')
@app.route('/<section>')
def home(section="top"):
    return render_template('app.html', section=section)
Beispiel #25
0
        if not result:
            abort(404, message="Post Id does not exist...")

        if args['user_id']:
            result.user_id = args['user_id']
        if args['title']:
            result.title = args['title']
        if args['description']:
            result.description = args['description']
        if args['image']:
            result.image = args['image']
        if args['date']:
            result.date = args['date']
        if args['condition']:
            result.condition = args['condition']

        db.session.commit()

        return result

    @marshal_with(resource_fields_item)
    def delete(self, ID):
        # ...
        return '', 204


api.add_resource(Item, '/item/<int:ID>')

if __name__ == '__main__':
    app.run(debug=True)
Beispiel #26
0
from config import api
from .resourceMonitor import getMonitor, getTasksFailure, getTasksSuccess, getTasksPending, getTasksWorker1, getTasksWorker2
'''Endpoints'''
api.add_resource(getMonitor, '/monitor/allTasks')
api.add_resource(getTasksFailure, '/monitor/taskFailure')
api.add_resource(getTasksSuccess, '/monitor/taskSuccess')
api.add_resource(getTasksPending, '/monitor/taskPending')
api.add_resource(getTasksWorker1, '/monitor/taskWorker1')
api.add_resource(getTasksWorker2, '/monitor/taskWorker2')
Beispiel #27
0
def add_restaurant_api():
    api.add_resource(RestaurantList, '/restaurants/')
    api.add_resource(Restaurants, '/restaurants/<id>')
Beispiel #28
0
from config import app, api
from flask import Flask, jsonify, request
import json
import resource

# customer registration route method:post
api.add_resource(resource.CustomerRegistration, '/customer/registration')
# customer login route method:post
api.add_resource(resource.CustomerLogin, '/customer/login')
# get a customer details by vendor
api.add_resource(resource.Customer, '/customer/<int:customer_id>')
# get all orders made by a customer method:get,post
api.add_resource(resource.CustomerOrders, '/customer/orders')
# get a single order made by customer method: get/patch/delete
api.add_resource(resource.CustomerOrder, '/customer/orders/<int:order_id>')
# get all customers details by vendor  method:get
api.add_resource(resource.AllCustomers, '/customers')
# get all products by customer or vendor method:get,post
api.add_resource(resource.AllProducts, '/products')
# get a specific product  method: get/patch/delete
api.add_resource(resource.Product, '/product/<int:product_id>')
# vendor registration route method:post
api.add_resource(resource.VendorRegistration, '/vendor/registration')
# vendor login route method:post
api.add_resource(resource.VendorLogin, '/vendor/login')
# get all orders made to a vendor method:get,post
api.add_resource(resource.AllOrders, '/vendor/orders')
# vendor get a specific order method: get/patch/delete
api.add_resource(resource.Order, '/vendor/order/<int:order_id>')
# vendor get all categories method:get,post
api.add_resource(resource.Categories, '/vendor/categories')
Beispiel #29
0
import os
from config import app,api
from api.Dataset import Dataset

api.add_resource(Dataset,'/api/dataset')


if __name__ == "__main__":
     app.run(host='0.0.0.0',port=5004, debug=True)