Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
d789f9eafd | |||
d1a6b17920 | |||
7cf8cef8cf | |||
1c4fd23e76 | |||
dc67c7eb10 | |||
82bd76618c | |||
b0027575b6 | |||
e79f2840d7 | |||
2db6e18d5b | |||
42ee9326ae |
16
README.md
16
README.md
@ -1,6 +1,12 @@
|
|||||||
# Forum App with FastAPI
|
# Singleboard Forum
|
||||||
Model is after 4chan
|
A 4ch ripoff, coded as an exercise in learning full stack development with React
|
||||||
|
and FastAPI.
|
||||||
|
|
||||||
Board: has threads, unique counter for posts
|
## Demo
|
||||||
Thread: Collection of related posts
|
Start the Docker containers:
|
||||||
Post: post_id, thread_id, title, content
|
```
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Interact with the backend API to add some posts by browsing to http://localhost:8000/docs,
|
||||||
|
then browse to the frontend at http://localhost:3000.
|
||||||
|
@ -5,7 +5,7 @@ services:
|
|||||||
context: ./backend
|
context: ./backend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '8001:8000'
|
- '8000:8000'
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
@ -13,7 +13,7 @@ services:
|
|||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '8000:8000'
|
- '3000:3000'
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
@ -1,4 +1,22 @@
|
|||||||
# Forum Frontend
|
# Forum Frontend
|
||||||
Should be extremely simple to start with no styling.
|
The frontend for the forum is written in React.
|
||||||
|
|
||||||
Node.js with a nice framework should be the ultimate goal, but could just do simple HTML and JS by hand for now.
|
**Note**: Before running, update the `apiUrl` in `app/src/App.js` to point your backend.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
To start the frontend in development mode and serve on http://localhost:3000:
|
||||||
|
```shell
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
## Production
|
||||||
|
```shell
|
||||||
|
# Install serve
|
||||||
|
npm install -g serve
|
||||||
|
|
||||||
|
# Build for production
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# Serve
|
||||||
|
serve -s --no-clipboard build
|
||||||
|
```
|
||||||
|
@ -3,11 +3,13 @@ import {useEffect, useState} from "react";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import PostList from "./components/Post/PostList";
|
import PostList from "./components/Post/PostList";
|
||||||
|
|
||||||
|
const apiUrl = "http://localhost:8000";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [postList, setPostsList] = useState([]);
|
const [postList, setPostsList] = useState([]);
|
||||||
|
|
||||||
const fetchPosts = async () => {
|
const fetchPosts = async () => {
|
||||||
await axios.get("http://localhost:8000/catalog")
|
await axios.get(apiUrl + "/catalog")
|
||||||
.then((response) => { setPostsList(response.data)})
|
.then((response) => { setPostsList(response.data)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
server {
|
|
||||||
listen 8000 default_server;
|
|
||||||
listen [::]:8000 default_server;
|
|
||||||
|
|
||||||
root /app;
|
|
||||||
index index.html;
|
|
||||||
server_name _;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /api {
|
|
||||||
proxy_pass http://backend:8000/;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user