Yeah boi.
This commit is contained in:
parent
24ea332aff
commit
b3b3303213
|
@ -1,4 +1,5 @@
|
||||||
```bash
|
```bash
|
||||||
cd server/
|
cd server/
|
||||||
source activate.sh
|
source activate.sh
|
||||||
|
run
|
||||||
```
|
```
|
||||||
|
|
|
@ -15,5 +15,5 @@ if (( $FIRST_RUN )); then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
python -m
|
python -m nightr
|
||||||
}
|
}
|
||||||
|
|
4
server/nightr/__main__.py
Normal file
4
server/nightr/__main__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
from .app import main
|
||||||
|
main()
|
43
server/nightr/app.py
Normal file
43
server/nightr/app.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import inspect
|
||||||
|
import statistics
|
||||||
|
|
||||||
|
from flask import Flask, jsonify
|
||||||
|
|
||||||
|
from server.nightr.strategies import dmi, steam
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
strategies = {
|
||||||
|
# name: (weight, probability function)
|
||||||
|
"dmi": (1.0, dmi.probability),
|
||||||
|
"steam": (0.5, steam.lol),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/", methods=["GET", "POST"])
|
||||||
|
def probabilities():
|
||||||
|
phone_data = None # TODO
|
||||||
|
|
||||||
|
probs = []
|
||||||
|
for name, (weight, strategy) in strategies.items():
|
||||||
|
prob = strategy(phone_data)
|
||||||
|
probs.append({
|
||||||
|
"name": name,
|
||||||
|
"doc": inspect.getdoc(strategy),
|
||||||
|
"prob": prob * weight,
|
||||||
|
})
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"strategies": probs,
|
||||||
|
"mean": statistics.mean(p["prob"] for p in probs),
|
||||||
|
"median": statistics.median(p["prob"] for p in probs),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app.run(host='0.0.0.0')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
6
server/nightr/strategies/dmi.py
Normal file
6
server/nightr/strategies/dmi.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
def probability(phone_data) -> float:
|
||||||
|
"""
|
||||||
|
The data from DMI.
|
||||||
|
"""
|
||||||
|
return 0.63
|
3
server/nightr/strategies/steam.py
Normal file
3
server/nightr/strategies/steam.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
def lol(phone_data) -> float:
|
||||||
|
return 0.21
|
|
@ -1 +1,2 @@
|
||||||
Flask==1.0.2
|
Flask==1.0.2
|
||||||
|
requests==2.21.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user