-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathapi.py
46 lines (35 loc) · 1.13 KB
/
api.py
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
from fastapi import FastAPI
from wenmerge_api import *
from dotenv import load_dotenv
from fastapi.middleware.cors import CORSMiddleware
load_dotenv()
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:80"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
if 'TIME_TARGET' in os.environ:
target=(int(os.environ['TIME_TARGET']))
if 'TTD_TARGET' in os.environ:
target_ttd=(int(os.environ['TTD_TARGET']))
@app.get("/ttd_prediction_timestamp")
async def projected_timestamp_when_ttd_target_is_reached():
return estimate_ttd(target_ttd)
@app.get("/ttd_prediction")
async def projected_timestamp_when_ttd_target_is_reached():
return time.ctime(estimate_ttd(target_ttd))
@app.get("/time_prediction")
async def projected_td_at_time_target():
return estimate_time(target)
@app.get("/target_time")
async def time_target():
return time.ctime(target)
@app.get("/target_ttd")
async def ttd_target():
return target_ttd
@app.get("/hashrate")
async def daily_hashrate_and_date_projected_linearly_with_it():
return estimate_hashrate(target_ttd, target)