Skip to content

Commit

Permalink
Merge pull request #3 from loljoho/dir-layout-changes
Browse files Browse the repository at this point in the history
Change directory structure & add npm script to start front+backend to…
  • Loading branch information
loljoho authored Nov 3, 2020
2 parents f907f66 + f9d78fe commit 9d3c50c
Show file tree
Hide file tree
Showing 21 changed files with 623 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ tags
# -------------------------------

.vscode/*
!.vscode/settings.json
# !.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
Expand Down
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,81 @@
# neow

haha f1 car go neow
Frontend was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) & backend is a Python Flask app.

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the frontend in the build-watch development mode (no server) & start the backend server.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will **NOT** reload if you make edits.

### `npm start-frontend`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test-frontend`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build-frontend`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject-frontend`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

### `npm run start-backend`

Start the backend Python Flask server in development mode.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build-frontend` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
39 changes: 27 additions & 12 deletions api.py → backend/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from flask import Flask, jsonify
from flask import Flask
from flask_restful import Resource, Api
from waitress import serve
import os
import requests

app = Flask(__name__)
app = Flask(__name__, static_folder='../build', static_url_path='')


@app.route('/')
def index():
return app.send_static_file('index.html')


api = Api(app)


Expand Down Expand Up @@ -101,15 +110,21 @@ def get(self):


# API Routes
api.add_resource(ErgastRaceAPI, '/races')
api.add_resource(ErgastResultAPI, '/results')
api.add_resource(ErgastQualifyingAPI, '/qualifying')
api.add_resource(ErgastDriverAPI, '/drivers')
api.add_resource(ErgastTeamAPI, '/teams')
api.add_resource(ErgastDriverStandingAPI, '/driverStandings')
api.add_resource(ErgastConstructorStandingAPI, '/constructorStandings')
api.add_resource(ErgastCircuitAPI, '/circuits')
api.add_resource(ErgastStatusAPI, '/status')
api.add_resource(ErgastRaceAPI, '/api/races')
api.add_resource(ErgastResultAPI, '/api/results')
api.add_resource(ErgastQualifyingAPI, '/api/qualifying')
api.add_resource(ErgastDriverAPI, '/api/drivers')
api.add_resource(ErgastTeamAPI, '/api/teams')
api.add_resource(ErgastDriverStandingAPI, '/api/driverStandings')
api.add_resource(ErgastConstructorStandingAPI, '/api/constructorStandings')
api.add_resource(ErgastCircuitAPI, '/api/circuits')
api.add_resource(ErgastStatusAPI, '/api/status')

if __name__ == '__main__':
app.run(debug=True)
port = int(os.environ.get('PORT', 5000))

env = os.environ.get('FLASK_ENV', 'development')
if env == 'production':
serve(app, port=port)
else:
app.run(debug=True, port=port)
5 changes: 4 additions & 1 deletion requirements.txt → backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

## The following requirements were added by pip freeze:
aniso8601==8.0.0
astroid==2.4.1
autopep8==1.5.4
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
Expand All @@ -13,11 +14,13 @@ Jinja2==2.11.2
lazy-object-proxy==1.4.3
MarkupSafe==1.1.1
mccabe==0.6.1
pycodestyle==2.6.0
pylint==2.5.2
pytz==2020.1
requests==2.24.0
six==1.15.0
toml==0.10.1
urllib3==1.25.11
waitress==1.4.4
Werkzeug==1.0.1
wrapt==1.12.1
70 changes: 0 additions & 70 deletions client/README.md

This file was deleted.

Loading

0 comments on commit 9d3c50c

Please sign in to comment.