-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (32 loc) · 934 Bytes
/
main.py
File metadata and controls
38 lines (32 loc) · 934 Bytes
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from scraper import extract_data
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def root():
return {
"Information": {
"API URL Prefix": "/api",
"Endpoints": "Any available stackoverflow tag should work",
"Examples": {
"Python": "/api/python",
"JavaScript": "/api/javascript",
"ReactJS": "/api/reactjs",
"C#": "/api/csharp",
"C++": "/api/c++",
"Go": "/api/go",
},
"Timestamp": "GMT+2 Timezone"
}
}
@app.get("/api/{language}")
async def get_questions(language: str):
data = extract_data(tags=[language], max_pages=1)
return data