A python=3.9-asyncio-based web backend, using web framework fastapi.
- We have deployed our backend website on https://be.rdogs.dodofk.xyz/docs. No need to start the server on your local environment.
- API 討論文件: https://hackmd.io/@icheft/S1guJIOBY
- Please ask develop team to get .env file.
There two ways to setup your database.
- You only have to ask developer to get .env file.
-
First, import
schemas.sqlto postgresql serverpsql -U your_user_name -d new_db_name -f schemas.sql -
Second, on your postgresql cmd:
# please remember to replace your path \COPY location(name) FROM '/path/fds-be/data_collection/location.csv' DELIMITER ',' CSV HEADER; \COPY category(name) FROM '/path/fds-be/data_collection/category.csv' DELIMITER ',' CSV HEADER; \COPY department(school, department_name) FROM '/path/fds-be/data_collection/department.csv' DELIMITER ',' CSV HEADER;or in your postgresql cmd:
\i import_data.sql -
Finally, revise .env file to connect to your local database.
PG_HOST=postgresql://localhost PG_PORT=5432 PG_USERNAME=your_username PG_PASSWORD=your_password PG_DBNAME=your_dbname PG_DBURL= postgresql://your_username:your_password@localhost/your_dbname
(name whatever you like)
conda create --name fds-async python=3.9
conda activate fds-asyncor
python3 -m venv fds-async
./fds-async/Scripts/activate
or create a virtual environment using pipenv (faster and lighter)
pip install pipenv
pipenv shellpip install -r requirements.txt
copy .env.example .envOr on Unix-based system, run
pip install -r requirements.txt
cp .env.example .envThen fill out the environment variables in .env
pip install uvicorn
uvicorn main:appOn your terminal you should see:
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process xxxx using watchgod
INFO: Started server process xxxx
INFO: Waiting for application startup.
INFO: Application startup complete.
Now you can go to http://127.0.0.1:8000 and test it.
You may also turn up the auto-reload option, or change the host & port with --host and --port:
uvicorn main:app --reload --host 0.0.0.0 --port 80