Creating a custom Web App using the Figshare API
This was demonstrated during the workshop. ChatGPT was used to show how a non-expert can build their own custom web app. Both the workshop example and a complete example are available and require Python installed on your machine. Run the Python script and point your browser to http://localhost:5000.
- Workshop demonstration files that set up a Python server and a basic HTML page to show titles from a Figshare sandbox environment:
- Workshop chatGPT prompts and responses
- Wokshop example zipped file with Python code and HTML page (downloads a zip file)
- Similar to above, but this complete example shows titles and views for records from the sandbox:
Development environment and tools
Visual Studio
- https://code.visualstudio.com/
- https://code.visualstudio.com/docs/python/python-tutorial
- https://code.visualstudio.com/docs/python/environments
Server
Web interface
- React: https://react.dev/
Code generation
- ChatGPT: https://chat.openai.com/
Generate code with ChatGPT:
See the pdf examples above for how to refine the prompts.
- Generate Python code for a web server that serves a static file
- Generate a HTML file with a React app that displays the results of a HTTP call
- Generate Python code for a Flask GET route that has a query parameter and returns JSON
Other useful documentation:
Security considerations:
- CORS: Abbreviation for cross-origin resource sharing
- Mechanism which indicates from what origins (http://localhost:5000 in our case) a browser is allowed to make HTTP API requests
- Security feature which prevents malicious sites stealing user information from legitimate sites
- By default Figshare’s API does not allow cross-origin requests
- Solutions:
- Make API requests via a (proxy) server