forked from dspytdao/vercel-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
23 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,52 @@ | ||
from flask import Flask, Response | ||
"""nonempty""" | ||
import os | ||
import json | ||
import requests | ||
from flask import Flask, Response, request, jsonify | ||
|
||
import pandas as pd | ||
import numpy as np | ||
#from statsmodels.tsa.arima.model import ARIMA | ||
|
||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/', defaults={'path': ''}) | ||
URL ='https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3' | ||
|
||
headers = {'Content-Type': 'application/json', | ||
'Authorization': os.environ.get("API_KEY")} | ||
|
||
URL ='https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3' | ||
|
||
@app.route("/", methods=["GET","POST"], defaults={'path': ''}) | ||
def home(): | ||
"""prediction""" | ||
if request.args.get('f'): | ||
f = int(request.args.get('f')) | ||
else: | ||
f=15 | ||
if request.args.get('a'): | ||
address = request.args.get('a') | ||
else: | ||
address = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984" | ||
|
||
query = """ | ||
{token (id: "%s"){tokenDayData { priceUSD date } } } | ||
""" % address | ||
|
||
r = requests.post(URL, json={'query': query}) | ||
json_data = json.loads(r.text) | ||
df_data = json_data['data']['token']['tokenDayData'] | ||
df = pd.DataFrame(df_data) | ||
|
||
df.priceUSD = df.priceUSD.replace(0, np.nan).dropna() | ||
df.priceUSD = df.priceUSD.astype(float) | ||
|
||
last = df.date.iloc[-1:].values[0] | ||
timestep = df.date.iloc[-1:].values[0]-df.date.iloc[-2:-1].values[0] | ||
|
||
return jsonify({ 'last_date': str(last), 'timestep': str(timestep)}) | ||
@app.route('/<path:path>') | ||
def catch_all(path): | ||
return Response("<h1>Flask</h1><p>You visited: /%s</p>" % (path), mimetype="text/html") | ||
"""check""" | ||
return Response("<h1>Flask</h1><p>You visited: /%s</p>" % (path), mimetype="text/html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
certifi==2022.9.24 | ||
charset-normalizer==2.1.1 | ||
click==8.1.3 | ||
Flask==2.2.2 | ||
idna==3.4 | ||
itsdangerous==2.1.2 | ||
Jinja2==3.1.2 | ||
MarkupSafe==2.1.1 | ||
numpy==1.23.3 | ||
packaging==21.3 | ||
pandas==1.5.0 | ||
patsy==0.5.2 | ||
pyparsing==3.0.9 | ||
python-dateutil==2.8.2 | ||
pytz==2022.4 | ||
requests==2.28.1 | ||
scipy==1.9.1 | ||
six==1.16.0 | ||
statsmodels==0.13.2 | ||
urllib3==1.26.12 | ||
Werkzeug==2.2.2 | ||
cowpy==1.0.3 |