コード例 #1
0
ファイル: api.py プロジェクト: nbhatia823/vibe-server
def search_handler():
    if request.method == 'GET':
        query = request.args.get('q')
        if query == None:
            return Response(status=400)
        else:
            data = Search.search(query)
            return Response(json.dumps(data),
                            mimetype='application/json',
                            status=200)
コード例 #2
0
ファイル: bminfo.py プロジェクト: m0untainxd/bminfo
    def idsubmit(self):

        try:
            self.mapID = int(self.bmid_ent.get())
            self.mapsetID = int(self.bmsid_ent.get())
        except ValueError:
            messagebox.showerror(
                title="Error",
                message="ValueError: must enter a number. Please try again.")
            return

        load_dotenv()
        self.BMINFO_KEY = os.getenv('BMINFO_KEY')

        global search
        search = Search(self.BMINFO_KEY)

        if self.mapID != 0 and self.mapsetID == 0:
            search.setmapID(self.mapID)
            map_data = search.api_mapID()

            if map_data == []:
                messagebox.showerror(
                    title="Error",
                    message="BeatmapID not found, please try again.")
                return
            else:
                pass

            for data in map_data:
                global beatmap
                beatmap = Beatmap(data["beatmap_id"], data["beatmapset_id"],
                                  data["title"], data["artist"],
                                  data["version"], data["creator"],
                                  float(data["diff_approach"]),
                                  float(data["diff_size"]),
                                  float(data["diff_overall"]),
                                  float(data["diff_drain"]),
                                  float(data["difficultyrating"]),
                                  int(data["hit_length"]), int(data["bpm"]))

            self.mainwindow()

        elif self.mapsetID != 0 and self.mapID == 0:
            search.setmapsetID(self.mapsetID)
            diffs = search.api_mapsetID()

            if diffs == []:
                messagebox.showerror(
                    title="Error",
                    message="BeatmapsetID not found, please try again.")
                return
            else:
                pass

            self.diff_list = sorted(
                diffs, key=operator.itemgetter('difficultyrating'))
            self.diff_names = []
            self.song_title = self.diff_list[0]["title"]
            self.song_artist = self.diff_list[0]["artist"]
            self.song_mapper = self.diff_list[0]["creator"]

            for diff in self.diff_list:
                self.diff_names.append(diff["version"])

            self.diffwindow()

        elif self.mapID != 0 and self.mapsetID != 0:
            msg = messagebox.askyesnocancel(
                title="Message",
                message=
                "Both values entered. BeatmapID will be used. Do you wish to continue?"
            )
            if msg == True:
                search.setmapID(self.mapID)
                map_data = search.api_mapID()

                for data in map_data:
                    beatmap = Beatmap(int(data["beatmap_id"]),
                                      int(data["beatmapset_id"]),
                                      data["title"], data["artist"],
                                      data["version"], data["creator"],
                                      float(data["diff_approach"]),
                                      float(data["diff_size"]),
                                      float(data["diff_overall"]),
                                      float(data["diff_drain"]),
                                      float(data["difficultyrating"]),
                                      int(data["hit_length"]),
                                      int(data["bpm"]))

                self.mainwindow()
            else:
                pass

        else:
            messagebox.showerror(title="Error",
                                 message="No value entered, please try again.")

        return
コード例 #3
0
ファイル: tweetsuite.py プロジェクト: NickQuantum/TweetSuite
@author: Quantum Solutions
"""



from flask import Flask, request, redirect, url_for
from flask import render_template, session
from flask.views import MethodView
from classes.search import Search
from classes.result import Result
from classes.utils import InitializeTweepyAPI

tweetsuite = application = Flask(__name__)
tweetsuite.secret_key = "social"                 # needed for sessions

class Mainline(MethodView):
    def get(self):
        session.pop('query', None)              # Reset query value in session
        session.pop('username', None)           # Reset username value in session
        initialize = InitializeTweepyAPI()
        return render_template('index.html')


    
tweetsuite.add_url_rule('/', view_func=Mainline.as_view('index'))
tweetsuite.add_url_rule('/search', view_func=Search.as_view('search'))
tweetsuite.add_url_rule('/result', view_func=Result.as_view('result'))
 
   
if __name__ == '__main__':
    tweetsuite.run(debug=False)
コード例 #4
0
class Demo(flask.views.MethodView):
    def get(self):
        print('Demo Page Invoked!!')
        return flask.render_template('demo_sna_graph.html')


#routes
tweetsuite.add_url_rule('/',
                        view_func=MainLine.as_view('index'),
                        methods=["Get", "POST"])
tweetsuite.add_url_rule('/login',
                        view_func=Login.as_view('login'),
                        methods=["Get", "POST"])
tweetsuite.add_url_rule('/search/',
                        view_func=Search.as_view('search'),
                        methods=['GET', 'POST'])
tweetsuite.add_url_rule('/register/',
                        view_func=Register.as_view('register'),
                        methods=['GET', 'POST'])
tweetsuite.add_url_rule('/result/',
                        view_func=Result.as_view('result'),
                        methods=['GET'])
tweetsuite.add_url_rule('/logout',
                        view_func=Logout.as_view('logout'),
                        methods=['GET'])
tweetsuite.add_url_rule('/demo',
                        view_func=Demo.as_view('demo'),
                        methods=['GET'])

コード例 #5
0

class Demo(flask.views.MethodView):
    def get(self):
        print('Demo Page Invoked!!')
        return flask.render_template('demo_sna_graph.html')

#routes
tweetsuite.add_url_rule('/',
                 view_func=MainLine.as_view('index'),
                 methods=["Get","POST"])
tweetsuite.add_url_rule('/login',
                 view_func=Login.as_view('login'),
                 methods=["Get","POST"])
tweetsuite.add_url_rule('/search/',
                 view_func=Search.as_view('search'), 
                 methods=['GET','POST'])
tweetsuite.add_url_rule('/register/',
                 view_func=Register.as_view('register'), 
                 methods=['GET','POST'])
tweetsuite.add_url_rule('/result/',
                 view_func=Result.as_view('result'), 
                 methods=['GET'])
tweetsuite.add_url_rule('/logout',
                 view_func=Logout.as_view('logout'),
                 methods=['GET'])
tweetsuite.add_url_rule('/demo',
                 view_func=Demo.as_view('demo'),
                 methods=['GET'])

#handler to page not found - or incorrect URL