Quick Start Guide

Welcome to Repl.it! This guide is meant to give you a quick overview of the many features of Repl.it. We're very excited to introduce you to a new workflow that can change the way you write code.

No programming knowledge is necessary. This quick start guide is in Python.

  1. Creating a New Python 3 Repl
  2. Renaming and Describing your Repl
  3. The Repl Environment
  4. Hello World!
  5. A Simple Input Program
  6. Adding Packages
  7. Creating Python Plots
  8. Starting a Web Server
  9. Adding Secret Keys
  10. Sharing Your Repl
  11. Sample Repls
  12. More from our Community
  13. Moving Forward

Creating a New Python 3 Repl

On your Repls Dashboard, you create a new repl by clicking on "Start Coding Now" or the red button in the bottom right corner. This will bring you to a page with a list of our supported languages.

Go ahead and select Python. This will bring you to your workspace.

More on the repls dashboard.

Renaming and Describing your Repl

The first thing to do when creating a repl is to give it a name and description. This will make it easier to come back to later, and will help with organizing your repls.

You can edit the name and description of the repl by clicking on the edit icon highlighted below, then editing the text fields to change the name and add a description. Clicking off the popover will automatically save any changes you've made.

The Repl Environment

There are three main parts to the Repl:

  1. The Sidebar, where you can find a variety of panes for files, the package manager, the debugger, live coding, and so on.
  2. The Editor, where you write code.
  3. The Console/Terminal, where you can interact with your code or evaluate code line-by-line.

Hello, World!

Let's start with the Console/Terminal. In that section, type in the following and hit enter:

print("Hello World!")

Here you can evaluate code line by line and interact with its results. Now let's try entering the following:

x = "hey"

Then type:

x * 3

Variables declared in the console persist, so you can continue to interact with variables there.

A Simple Input Program

Now let's move over to the Editor. Type in the following python code:

name = input("What's your name?")

print("Hello", name)

To run it, click on the big Run button at the top of the screen, or hit CTRL+Enter (Windows/Chromebook) / CMD+Enter (Mac).

You'll see the code run on the right hand side of the screen. Since the program is asking for input, go ahead and type your name in the console and hit enter. It should then greet you!

Adding Packages

Let's use the matplotlib package to make a simple plot. Clear the existing code, click on the packages icon on your sidebar, and enter matplotlib to search for the package. Select the first one (indicated by the arrow).

Click on the + button to add it to your packages.

This will create a new file, requirements.txt, which contains all the package information for your repl, including the version number. It will also start installing on the right.

We can view all of our files by selecting the filetree icon on our sidebar - the first icon. Click on the filetree icon, then select main.py to return to your program.

More on packages.

Creating Python Plots

Let's enter the following code:

import matplotlib as mpl
import matplotlib.pyplot as plt

plt.plot([1, 2, 4, 8, 16])

plt.savefig('plot.png')

Run the code. You'll see that the newly generated image, plot.png, shows up in both the filetree and below the editor so you can see it! Neat, huh?

More on plotting in Python.

Starting a Web Server

Let's create a new Python3 repl. As a shortcut, you can create a new repl by going directly to https://repl.it/languages/python3. Let's call this one "python flask server"

Our first step is to add the flask package. Go through the steps above except this time, choose the package called flask.

Once finished, go back to main.py and enter the following code:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_repler():
  return 'Hello, Repler!'

if __name__ == '__main__':
  app.run(host='0.0.0.0', port=8080)

Hit run, and you'll see that a new pane has appeared with the URL for your repl's hosted site, along with a preview of what it looks like. You can share this link with your friends to show them the simple app that you made.

More on web servers.

Adding Secret Keys

So far, your repl is public to everyone (unless you have a paid plan) and they can see the code that you put here. If you need to put some private information, such as an API key, or a database password, you can use .env files.

Create a new file by clicking on the File+ icon in your filetree. Name it .env.

.env files contain key-value pairs like the following. Type in:

PASSWORD=pass1234

This .env file is special because it is only visible to you. Anyone who is visiting your repl won't be able to see the contents of this file.

Now let's edit main.py to include the following:

from flask import Flask, request
import os
app = Flask(__name__)

@app.route('/')
def hello_world():
  return 'Hello, Repler!'

@app.route('/secure-page')
def secret_route():
  password = request.args.get('secret')
  if (password == os.environ['PASSWORD']):
    return 'You found the secret!'
  else:
    return 'Wrong password!'

if __name__ == '__main__':
  app.run(host='0.0.0.0', port=8080)

We're creating a new page where we look for a query param secret and we check to see if it matches our .env secret. Watch the video below to see the results.

Of course, this is a very insecure way of handling secret tokens, since the URL including the query parameter can be cached. This is just a simple demonstration.

More on env files

Sharing Your Repl

Finally, now that you've created your first repl, feel free to share it with our community!

Head on over to Repl Talk and check out the Share Board. Click on "Share your repl!", choose the repl from the list (or type the name to search), add a title and a description, and Share!

Feel free to join our Discord Community as well! Join with this invite link.

Sample Repls

If you're interested in exploring more in what you can do on Repl.it, take a look at the following repls:

More from our Community

You can find tutorials created by members of our community on Learn. There are tutorials for creating single player and multiplayer games, web apps, Discord bots, and AI programs. Be sure to give the post an upvote if you enjoyed it!

If you want to check out other cool repls that people have shared, you can find them on Share.

If you have a question about programming or need help debugging something, be sure to post on Ask. Someone will help you if they can!

Moving Forward

Enjoy being a Repler! We would love to hear more from you about how you use Repl.it, how you found out about Repl.it, and if there's anything we can do to improve. Feel free to contact us through any of the following avenues: