-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
56 lines (43 loc) · 1.16 KB
/
main.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
47
48
49
50
51
52
53
54
55
56
# pip install "fastapi[all]"
# pip3 install requests --user
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import requests
from fastapi.responses import HTMLResponse, FileResponse
origins =["*"]
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/routes")
async def root():
r = requests.get('https://gocomo.doublemap.com/map/v2/routes')
return r.json()
@app.get("/buses")
async def root():
r = requests.get('https://gocomo.doublemap.com/map/v2/buses')
return r.json()
@app.get("/stops")
async def root():
r = requests.get('https://gocomo.doublemap.com/map/v2/stops')
return r.json()
#return STATIC html
@app.get("/", response_class=HTMLResponse)
async def read_items():
f = open("index.html", "r")
fileContent = f.read()
f.close()
return fileContent
@app.get("/audio", response_class=FileResponse)
async def main():
return "audio.mp3"
@app.get("/dot.png", response_class=FileResponse)
async def main():
return "dot.png"
@app.get("/version")
async def main():
return "1.0"