-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
58 lines (48 loc) · 1.7 KB
/
server.py
File metadata and controls
58 lines (48 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from flask import Flask, jsonify
from flask_restful import Resource, reqparse, Api
import json
import random
import werkzeug
from werkzeug.security import safe_str_cmp
import pymongo
import hashlib
from utils.random_string import random_string
conn = pymongo.MongoClient('mongodb://root:arin4242@localhost:27017')#database connecting
db = conn.toto
collection = db.info
app = Flask(__name__)
api = Api(app)
class signUp(Resource):
def get(self):
code = random_string(6)
return {'code': code}
class bet(Resource):
def post(self):
parser = reqparse.RequestParser()
parser.add_argument("code", type = str, required = True)
parser.add_argument("bet")
args = parser.args()
class auth(Resource):
def post(self):
parser = reqparse.RequestParser()
parser.add_argument('code', type = str, required = True)
args = parser.parse_args()
if collection.distinct(args)[0]['balance']:
return collection.distinct(args['code'])[0]['balance']
return {'msg':'wrong code'}
class history(Resource):
def get(self):
return collection.distinct("code")[0]['history']
class bet2(Resource):#genius
def post(self):
parser = reqparse.RequestParser()
parser.add_argument('code', type = str, required = True)
parser.add_argument("bet", type = str, required = True)
parser.add_argument("quan", type = int, required = True)
parser.add_argument("odds", type = float, required = True)
parser.add_argument("predict", type = int, reqired = True)
args = parser.parse_args()
if collection
collection.insert()
api.add_resource(bet2, '/')
app.run(port=5000)