-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (28 loc) · 827 Bytes
/
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
from fastapi import FastAPI
from typing import List
from fastapi.middleware.cors import CORSMiddleware
import scraper
app = FastAPI(
title="Musica API",
description="Musica API is a simple API that allows you to search and download music from the internet.",
version="1.0.0",
redoc_url=None,
deprecated=False
)
# allow CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["GET"],
allow_headers=["*"]
)
@app.get("/search/{query}")
async def get_search_results(query: str) -> List[dict]:
return await scraper.search(query)
@app.get("/getSong/{query}")
async def get_song_link(query: str) -> str:
return await scraper.get_song(query)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=10000)