Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python server #209

Merged
merged 9 commits into from
Apr 29, 2021
Merged

Add Python server #209

merged 9 commits into from
Apr 29, 2021

Conversation

tamsingreen
Copy link
Contributor

@tamsingreen tamsingreen commented Apr 20, 2021

Is your Pull Request request related to another issue in this repository ?
bbc/digital-paper-edit-infrastructure#21

Describe what the PR does

  • Add a simple Python server for use on the deployed DPE EC2. Works in conjunction with this PR in the infrastructure project. It has a /status healthcheck endpoint for AWS use, and all other requests fall back to /index.html where the React app is served from.
  • Adds an isProduction() function to check whether Dev/Test or Prod/Live config should be used (this is added through the build process in the digital-paper-edit-infrastructure project).
  • Changes some const variables to letwhere reassignment was causing read-only errors when deployed

State whether the PR is ready for review or whether it needs extra work
RFR

How to test

  1. npm run build
  2. cd build
  3. python server.py
  4. Go to http://localhost:8080
  5. Check the app name appears in the page header (this shows that env variables are working correctly - ask Tamsin or Alli for the updated config)
  6. Log in and create a new project, update the name of a project, and add a new programme script to a project (this shows the read-only errors are fixed)

Copy link
Contributor

@emettely emettely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this already deployed?

public/server.py Show resolved Hide resolved
@tamsingreen
Copy link
Contributor Author

Is this already deployed?

No, the infra project is pulling from this branch.

@emettely
Copy link
Contributor

Is this already deployed?

No, the infra project is pulling from this branch.

This probably should be put in the infra repository than this one. I say this because this has not very much to do with the actual Firebase / open source project, but a lot to do with the AWS / Cosmos side of things.

allishultes and others added 5 commits April 23, 2021 11:36
* Bump react-dev-utils from 11.0.3 to 11.0.4 (#193)

Bumps [react-dev-utils](https://github.com/facebook/create-react-app/tree/HEAD/packages/react-dev-utils) from 11.0.3 to 11.0.4.
- [Release notes](https://github.com/facebook/create-react-app/releases)
- [Changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG-1.x.md)
- [Commits](https://github.com/facebook/create-react-app/commits/HEAD/packages/react-dev-utils)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Deal with unhandled exceptions in Admin view (#204)

* Deal with unhandled exceptions in Admin view.

[fix] add default params to Transcripts view. Unsure when the bug was introduced.
Also had to change the admin role - not sure when this was changed either.

* [fix] Actually should have a better error message

* [fix] Better message

* refactor(env): #198 Add logic to handle both test and live envs at build

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eimi Okuno <[email protected]>
@tamsingreen tamsingreen linked an issue Apr 27, 2021 that may be closed by this pull request
5 tasks
@tamsingreen tamsingreen linked an issue Apr 27, 2021 that may be closed by this pull request
@tamsingreen
Copy link
Contributor Author

Is this already deployed?

No, the infra project is pulling from this branch.

This probably should be put in the infra repository than this one. I say this because this has not very much to do with the actual Firebase / open source project, but a lot to do with the AWS / Cosmos side of things.

This is true but it's a simple, generic server with no BBC-specific config so I'm happy for it to belong in this repo.

Copy link
Contributor

@allishultes allishultes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, Tamsin - hero status for your fixes with the lets / consts!

@aniablaziak aniablaziak self-requested a review April 28, 2021 14:20
const isProduction = () => {
const parsedUrl = url.parse(window.location.href, true);

if ((parsedUrl.host) === 'digital-paper-edit.tools.bbc.co.uk') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be simplified? e.g.

return parsedUrl.host === 'digital-paper-edit.tools.bbc.co.uk'

or does this make it less clear?

Copy link
Contributor

@sarahrainbow sarahrainbow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great and works for me! Just had one comment that may not need addressing!

import http.server
import socketserver
class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
import SimpleHTTPServer, SocketServer
Copy link
Contributor

@aniablaziak aniablaziak Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to use python2? Why is that?

Using python3 I had to change it back to:
import http.server, socketserver

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good q - the EC2 we use has python 2 by default (as does my Mac :) )

@bevand10
Copy link

bevand10 commented Apr 28, 2021 via email

@tamsingreen tamsingreen merged commit 980dfa8 into master Apr 29, 2021
@tamsingreen tamsingreen deleted the server branch April 29, 2021 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up Firebase project for Cosmos deployment
6 participants