コード例 #1
0
def update_user(user_id):
    user = {}
    user['id'] = user_id
    key_list = request.json.keys()
    for i in key_list:
        user[i] = request.json[i]
    return jsonify({'status': Requests.upd_user(user)}), 200
コード例 #2
0
def add_tweets():
    print ("add tweet")
    user_tweet = {}
    if not request.json or not 'username' in request.json or not 'body' in request.json:
        abort(400)
    user_tweet['tweetedby'] = request.json['username']
    user_tweet['body'] = request.json['body']
    user_tweet['created_at']=strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    user_tweet['id'] = random.randint(1,1000)
    return jsonify({'status': Requests.add_tweet(user_tweet)}), 201
コード例 #3
0
def create_user():
    if not request.json or not 'username' in request.json or not 'email' in request.json or not 'password' in request.json:
        abort(400)
    user = {
        'username': request.json['username'],
        'email': request.json['email'],
        'name': request.json.get('name', ""),
        'password': request.json['password'],
        'id': random.randint(1, 1000)
    }
    return jsonify({'status': Requests.add_user(user)}), 201
コード例 #4
0
def add_tweets():
    user_tweet = {}
    if not request.json or not 'tweetedby' in request.json or not 'body' in request.json:
        abort(400)

    user_tweet['tweetedby'] = request.json['tweetedby']
    user_tweet['body'] = request.json['body']
    user_tweet['created_at'] = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    if len(user_tweet) == 0:
        return 405
    return jsonify({'status': Requests.add_tweet(user_tweet)}), 201
コード例 #5
0
def update_user(user_id):
    user = {}
    if not request.json:
        abort(4000)

    user['id'] = user_id
    key_list = request.json.keys()
    for i in key_list:
        user[i] = request.json[i]
    print(user)
    return jsonify({'status': Requests.upd_user(user)}), 200
コード例 #6
0
    def __init__(self,
                 client_id: str,
                 client_secret: str,
                 redir_url: str = "http://*****:*****@gmail.com>"
        })

        self._db_ses = db_ses()
コード例 #7
0
def get_tweet(id):
    return Requests.list_tweet(id)
コード例 #8
0
def get_tweets():
    return Requests.list_tweets()
コード例 #9
0
def delete_user():
    if not request.json or not 'username' in request.json:
        abort(400)
    user=request.json['username']
    return jsonify({'status': Requests.del_user(user)}), 200
コード例 #10
0
def get_user(user_id):
    return Requests.list_user(user_id)
コード例 #11
0
def get_users():
    return Requests.list_users()
コード例 #12
0
timeline = []
for i in range(0, number_of_requests):
    timeline.append(time[i] + holding_time[i])

timeNew = time + timeline
# print("before",timeNew)

for i in range(len(timeNew)):
    for j in range(len(timeNew) - 1 - i):
        if timeNew[j] > timeNew[j + 1]:
            timeNew[j], timeNew[j + 1] = timeNew[j + 1], timeNew[j]

Req = []
for i in range(0, number_of_requests):
    req = Requests(time[i], timeline[i], source[i], destination[i], i)
    Req.append(req)

Events = []
for i in range(len(timeNew)):
    for req in Req:
        if req.inTime == timeNew[i]:
            Events.append(req)
        elif req.outTime == timeNew[i]:
            temp = cp.copy(req)
            temp.isCall = 1
            Events.append(temp)

print(len(Events))

コード例 #13
0
class Presentation(object):
    '''
    Helper Class to create easily the SuisseId Login forms. Both methods are supportet:
    
    Direct:
        User gets automatically redirected to the IDP without any further actions/clicks required
    
    Indirect:
        Returns an login Button which can get placed anywhere on the website.
    '''
    
    setting = None
    
    request = None
    
    def __init__(self, setting):
        '''
        Stores the settings and builds the saml2 request
        '''
        self.setting = setting
        self.request = Requests(self.setting)

    def login(self, direct = False):
        '''
        Helper method to return the requested login method
        '''
        if direct:
            return self._loginRedirect()
        return self._loginIndirect()

    def _loginIndirect(self):
        '''
        Builds the Indirect login form
        '''
        request = self.request.authnRequest()
        data = """<form method="POST" action="%(url)s">
            <input type="hidden" name="SAMLRequest" value="%(saml)s" />
            <input type="image" src="%(image)s" border="0" name="submit" alt="Go">
             </form>
        """ % {"url":self.setting.samlSsoEndpointUrl, "saml":request, "image":self.setting.image}
        
        return data
    
    def _loginRedirect(self):
        '''
        Builds the direct login form
        '''
        data = """<?xml version="1.0" encoding="UTF-8"?>
<html>
    <head>
        <title>SAML Authentication Request POST</title>
    </head>
    <body onload="document.forms[0].submit()">
    <form action="%(url)s" method="POST">
        <div>
            <input type="hidden" name="RelayState" value="some_preserved_data" />
            <input type="hidden" name="SAMLRequest" value="%(saml)s" />
         </div>
         <noscript>
            <div>
               <input type="submit" value="Continue" />
            </div>
         </noscript>
      </form>
   </body>
</html>""" % {"url":self.setting.samlSsoEndpointUrl, "saml":self.request.authnRequest()}
        return data
コード例 #14
0
from flask import Flask, render_template, url_for
from flask_pymongo import PyMongo

from config import *
from requests import Requests

app = Flask(__name__,
            static_folder=ASSETS_FOLDER,
            template_folder=TEMPLATE_FOLDER)
app.config.from_object('config')
data = PyMongo(app, config_prefix='MONGO')
requests = Requests(mongo=data)


@app.route("/")
@app.route("/create")
@app.route("/update/<todo_id>")
@app.route("/view/<todo_id>")
def entry_point():
    return render_template('index.html')


@app.route("/api", methods=["GET"])
def api():
    return "Todo API"


# Fetch
@app.route("/api/todos", methods=["GET"])
def todos_index():
    return requests.todos_index()
コード例 #15
0
from memory import MemoryCLOCK, MemoryFIFO
from requests import Requests

# Total number of request generated
NUM_REQUESTS = 100;
RAND_SEED = 4;
MAX_PAGE_NUM = 50;

# Maximum number of pages stored in memory
MEM_LEN = 20;

DEBUG = 0;

if __name__ == "__main__":

    requests = Requests(MAX_PAGE_NUM, RAND_SEED);

    print("Starting simulation ...");
    print("Total number of page faults will be measured for each algorithm. ");
    print("Number of page request generated: {0}".format(NUM_REQUESTS));

    print('---------------------------------------------------------------------')
    print('Type A request pattern: Uniform distribution')

    fifo = MemoryFIFO(MEM_LEN);
    clock = MemoryCLOCK(MEM_LEN);

    for x in range(NUM_REQUESTS):
        ran = requests.nextPage('uniform');
        fifo.readPage(ran);
        clock.readPage(ran);
コード例 #16
0
def get_tweet(tweetedby):
    return Requests.list_tweet(tweetedby)
コード例 #17
0
from flask import Flask, request, render_template, make_response, jsonify
from flask_pymongo import PyMongo
from requests import Requests
import json

app = Flask(__name__, static_folder="../static/dist",
            template_folder="../static")
app.config['MONGO_DBNAME'] = 'songs'
app.config['MONGO_URI'] = 'mongodb://*****:*****@ds137650.mlab.com:37650/songs'
mongo = PyMongo(app)
requests = Requests(mongo=mongo)


@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404


@app.route('/')
def index():
    try:
        # with open('songs.json', 'r') as f:
        #     comments = json.loads(f.read())
        #     songs = mongo.db.songs_collection.insert_many(comments)
        return render_template('index.html')
    except Exception:
        abort(404)


@app.route('/songs')
def get():
コード例 #18
0
 def __init__(self, setting):
     '''
     Stores the settings and builds the saml2 request
     '''
     self.setting = setting
     self.request = Requests(self.setting)