Skip to content

Commit

Permalink
temp push
Browse files Browse the repository at this point in the history
  • Loading branch information
MisileLab committed Oct 31, 2023
1 parent 4015426 commit 442b487
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 3 deletions.
2 changes: 1 addition & 1 deletion projects/xobusy/sunrint-decon/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MONGO_URI
config.toml

11 changes: 10 additions & 1 deletion projects/xobusy/sunrint-decon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

from fastapi import FastAPI, Header, status, HTTPException
from pymongo import MongoClient
from tomli import loads
from requests import get

config = loads(Path("config.toml").read_text())
app = FastAPI()
db = MongoClient(Path("MONGO_URI").read_text().strip())["local"]["schoolfinder"]
db = MongoClient(config["MONGO_URI"])["schoolfinder"]["login"]

async def is_valid(name: str, password: str) -> bool:
return db.find_one({"name":name,"password":password}) != None
Expand All @@ -23,3 +26,9 @@ async def register(

db.insert_one({"name":name,"password":password})

@app.get("/school/search")
async def school_search(name: str):
a = get("https://open.neis.go.kr/hub/schoolinfo",params={"KEY":config["NEIS_KEY"],"TYPE":"json","SCHUL_NM":name})
a.raise_for_status()
return a.json()["schoolInfo"][2]["row"]

161 changes: 160 additions & 1 deletion projects/xobusy/sunrint-decon/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions projects/xobusy/sunrint-decon/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ python = "3.12.0"
pymongo = "4.5.0"
fastapi = "0.104.1"
uvicorn = "0.23.2"
tomli = "2.0.1"
requests = "2.31.0"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit 442b487

Please sign in to comment.