Welcome to 2023! Here we have chatbots that can easily replace real humans!
OpenAI launched ChatGPT in November 2022.
We played with this bot, discovered some appealing applications, and forgot about it.
But then we thought: “What if we ask ChatGPT to build a file uploader page using Uploadcare?” Why not? It should be entertaining.
Instead of providing the context to the bot at the start, we decided to play a role of a junior developer.
Our “developer” heard something about frontend, HTML, CSS & JS, but they do not know much. This is why they ask a lot of newbie questions.
To make it easier to read: our questions are headlines, and ChatGPT’s answers are the normal text.
Italic text is our comments on the whole play.
We used the bot’s answers as is. The only thing we removed is the ubiquitous reminders that the bot is ready for any questions.
The bot says it at the end of each reply.
Here is a simple HTML webpage with a file input field that allows users to select a file to upload:
<html><body><form><labelfor="file">Select a file:</label><br><inputtype="file"id="file"name="file"><br><inputtype="submit"value="Submit"></form></body></html>
This HTML code creates a form with a file input field and a submit button.
When the user selects a file and clicks the submit button, the form will be submitted and the selected file will be uploaded.
To serve an HTML file on localhost, you will need to use a web server.
Here are the steps to serve an HTML file on localhost using a simple Python web server:
Install Python: Make sure you have Python installed on your computer.
You can check if Python is already installed by opening a terminal and entering the command python --version.
If Python is not installed, you can download and install it from the Python website.
Start the web server: Open a terminal and navigate to the directory that contains your HTML file.
Then start the Python web server by entering the following command:
python -m http.server 8000
This will start a web server on your local machine that listens on port 8000.
View the HTML file in your browser: Open a web browser and enter the following URL:
http://localhost:8000/your_html_file.html
Replace “your_html_file.html” with the name of your HTML file. This will open the HTML file in your browser.
This will include the Uploadcare widget library in your website.
Once you have added this script to your HTML, you can then use the widget to allow users to upload files from your website.
Here is an example of how you can do this:
<!-- HTML for file input --><inputtype="hidden"role="uploadcare-uploader"name="my_file"/><!-- JavaScript to initialize the widget --><script>UPLOADCARE_PUBLIC_KEY='your_public_key';var widget = uploadcare.Widget('[role=uploadcare-uploader]');</script>
In this example, the input element with the uploadcare-uploader role serves as a placeholder for the widget.
The JavaScript code initializes the widget and specifies your Uploadcare public key, which you can find in your account settings.
Again, it works:
We tested the widget, it works properly. But this is an old way to install our uploader.
Currently, we have a beta version of File Uploader, that is based on Uploadcare Blocks.
Let’s find out what the bot knows about it!
Uploadcare Blocks is a new way to build file uploaders and file handling workflows using pre-built UI components.
It allows you to easily add file uploading and file handling functionality to your website or application with minimal code.
To create a file uploading form using Uploadcare Blocks, you will need to do the following:
Sign up for an Uploadcare account: Go to the Uploadcare website and sign up for an account.
You will need to provide your email address and create a password.
Install the Uploadcare Blocks library: To use Uploadcare Blocks, you will need to include the Blocks library in your HTML code.
You can do this by adding the following script tag to your HTML:
Add a file input element to your HTML: To create a file uploading form using Uploadcare Blocks, you will need to add a file input element to your HTML code.
You can do this by using the following HTML:
This will create a file input element that will be used to select and upload files.
Initialize the Uploadcare Blocks library: To initialize the library set the Uploadcare public key when using the lr-file-uploader-regular element.
You can use the --cfg-pubkey attribute as a CSS context property. For example:
Replace “your_public_key” with your actual Uploadcare public key, which you can find in your account settings.
This will set the public key for the file uploader and allow it to connect to the Uploadcare API.
I apologize for the broken link. The correct URL for the Uploadcare Blocks library is https://unpkg.com/@uploadcare/blocks@0.14.3/web/blocks-browser.min.js.
You should use this URL to include the Blocks library in your HTML code.
To include the Blocks library in your HTML, you will need to add the following script tag to your HTML:
This will include the CSS styles for the Blocks library in your HTML, and should fix the CSS errors that you are seeing in the console.
Alternatively, you can use the css-src attribute on the lr-file-uploader-regular element to specify the URL of the CSS styles for the Blocks library. For example:
To display an image that you have uploaded to Uploadcare on your webpage, you will need to use an img element and set the src attribute to the URL of the image on Uploadcare’s servers.
For example:
<imgsrc="https://ucarecdn.com/image_id/">
Replace “image_id” with the actual ID of the image that you want to display.
You can find the ID of the image in the response that the Blocks library returns when you upload the image.
To resize the image to a specific size, you can use the -/resize/ operation in the URL of the image.
For example, to resize the image to 256×256 pixels, you can use the following URL:
To be honest, when we started the experiment we did not believe that ChatGPT could deal with it.
Sure, it’s a cool toy, and it even knows how to generate code examples related to your problem.
But we are surprised that the bot knows a lot about our new features, recent documentation, and so on.
It feels like you’re talking to an assistant who can google for you.
After the first rapture had passed, we asked ChatGPT more programming-related questions.
We would say that it generates code that looks like it should work.
If you do not know how to solve the problem, the code you get can mislead you because it is too convincing.
Besides, ChatGPT makes mistakes. In this article, we’ve encountered only one — the broken link.
But the more questions you ask, the more connected the bot’s answers are.
Sometimes they become too connected and start to affect each other.
E.g. ChatGPT adapts replies to the language or programming paradigm you prefer.
This “feature” sometimes leads to broken or unoptimized code.
Anyway, ChatGPT is still a handy tool to use. There are some use cases:
To collect a broad overview of some topics. E.g. you may ask about scientific concepts or discoveries.
When the bot answers, you may ask about relations to other concepts, key people in the field, and so on.
It’s like reading those Wikipedia snippets in Google, but you can get such a snippet for any of your questions.
Try: "Tell me, please, what Alan Turing’s most popular paper was about?"
To handle interactive chats on your website or app (no way!).
Or to help a human in a call center to find an answer in a bunch of documentation.
To generate blocks of boring text, like legal documents or official letters.
Sure, a lawyer should review the output, but the result is not that bad already.
Try: "I’m creating an Android game that does not collect any data. It is not even connected to the Internet. Do you mind generating the privacy policy for the game?"
To extract SEO keywords from the provided text. But we will see what Google thinks about it.
To simplify the description of a complex thing to the desired level.
E.g. try to copy-paste a science term definition from Wikipedia and ask ChatGPT to simplify it for a second-grade student.
To solve puzzles together. It can solve crosswords with ease. If you try hard, you can even explain the bot Wordle rules and get help with today’s word!
Finally, if you have a tech company, it’s interesting to see whether the bot can use your service.
The result of such a check may trigger you to improve the docs or to clarify the purpose of your product.
Give it a try, and, who knows, you may find ChatGPT a place in your toolset.
P.S. By the way, we generated an OpenGraph image and the image you see below via Midjourney, while ChatGPT helped us to write the text on that images.
Gosh, what a time to be alive!