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

Flask 1 #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
venv
*.egg-info
venv
*.egg-info
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2018 coding&&community

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2018 coding&&community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Launchpad
The website for students to access coding&&community curriculums online.

## Setup
Setup the virtual environment.
```
python3 -m venv venv
```
Every time you work on the project, start up venv:
```
. venv/bin/activate
```
Install Flask:
```
pip install Flask
```
Windows instructions at http://flask.pocoo.org/docs/1.0/installation/#installation

## Running for the first time
```
export FLASK_APP=launchpad
pip install -e .
flask run
```
Then go to your web browser, and navigate to http://localhost:5000

Instructions may be different on Windows.


# Launchpad
The website for students to access coding&&community curriculums online.
## Setup
Setup the virtual environment.
```
python3 -m venv venv
```
Every time you work on the project, start up venv:
```
. venv/bin/activate
```
Install Flask:
```
pip install Flask
```
Windows instructions at http://flask.pocoo.org/docs/1.0/installation/#installation
## Running for the first time
```
export FLASK_APP=launchpad
pip install -e .
flask run
```
Then go to your web browser, and navigate to http://localhost:5000
Instructions may be different on Windows.
14 changes: 7 additions & 7 deletions launchpad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import Flask
from launchpad.api import launchpad_api
from launchpad.explorer import explorer

app = Flask(__name__)
app.register_blueprint(launchpad_api, url_prefix='/api')
app.register_blueprint(explorer)
from flask import Flask
from launchpad.api import launchpad_api
from launchpad.explorer import explorer
app = Flask(__name__)
app.register_blueprint(launchpad_api, url_prefix='/api')
app.register_blueprint(explorer)
14 changes: 7 additions & 7 deletions launchpad/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import Blueprint

launchpad_api = Blueprint('launchpad_api', __name__, template_folder='templates')

@launchpad_api.route('/test')
def test():
return 'API test'
from flask import Blueprint
launchpad_api = Blueprint('launchpad_api', __name__, template_folder='templates')
@launchpad_api.route('/test')
def test():
return 'API test'
22 changes: 11 additions & 11 deletions launchpad/explorer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from flask import Blueprint

explorer = Blueprint('explorer', __name__, template_folder='templates')

@explorer.route('/')
def index():
return 'Explorer index'

@explorer.route('/test')
def test():
return 'Explorer test'
from flask import Blueprint
explorer = Blueprint('explorer', __name__, template_folder='templates')
@explorer.route('/')
def index():
return 'Explorer index'
@explorer.route('/test')
def test():
return 'Explorer test'
17 changes: 17 additions & 0 deletions launchpad/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Length, Email, EqualTo

class RegistrationForm(FlaskForm):
username = StringField('Username', validators=[DataRequired(), Length(min=2, max=20)])
email = StringField('Email', validators=[DataRequired(), Email()])
password = PasswordField('Password',validators=[DataRequired()])
confirm_password = PasswordField('Confirm Password',validators=[DataRequired(), EqualTo('password')])
submit = SubmitField('Sign Up')

class LoginForm(FlaskForm):
email = StringField('Email', validators=[DataRequired(), Email()])
password = PasswordField('Password',validators=[DataRequired()])
remember = BooleanField('Remember Me')
submit = SubmitField('Login')

51 changes: 51 additions & 0 deletions launchpad/oscp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from flask import Flask, render_template, url_for, flash, redirect
from forms import RegistrationForm, LoginForm
app = Flask(__name__)

app.config['SECRET_KEY'] = '\xa4>\xb5\xd3m\xcb\r\xb2\xf93\xd1\xc1~\x8bQ\xe4'

posts = [
{
'author': 'Jane Doe',
'title': 'Blog Post 2',
'content': 'Need help with...',
'date_posted': 'September 30, 2018'
},
{
'author': 'John Smith',
'title': 'test post',
'content': 'Second post content',
'date_posted': 'September 1, 2018'
}
]


@app.route("/")
@app.route("/home")
def home():
return render_template("home.html",posts=posts)

@app.route("/about")
def about():
return render_template("about.html",title='About')

@app.route("/myprojects")
def myprojects():
return render_template("myprojects.html",title='My Projects')

@app.route("/register", methods=['GET','POST'])
def register():
form = RegistrationForm()
if form.validate_on_submit():
flash(f'Account created for {form.username.data}!', 'success')
return redirect(url_for('home'))
return render_template('register.html', title = 'Register', form=form)

@app.route("/login")
def login():
form = LoginForm()
return render_template('login.html', title = 'Login', form=form)


if __name__ == '__main__':
app.run(debug=True)
28 changes: 28 additions & 0 deletions launchpad/static/Projects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"projects": [
{
"lang": "python",
"level": 1,
"description": "Get started with this beginner Python project!"
},
{
"lang": "java",
"level": 2,
"description": "Try this fun Java project!"
},
{
"lang": "c++",
"level": 2,
"description": "Try your skills with this great C++ project!"
},
{
"lang": "reactjs",
"level": 3,
"description": "Challenge yourself with this level 3 JavaScript library!"
}

],

"dataTitle": "Projects",
"version": 1.0
}
9 changes: 9 additions & 0 deletions launchpad/static/Style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.container{
margin-left: 8%;
}

.card:hover{
-webkit-box-shadow: -1px 9px 40px -12px rgba(0,0,0,0.75);
-moz-box-shadow: -1px 9px 40px -12px rgba(0,0,0,0.75);
box-shadow: -1px 9px 40px -12px rgba(0, 0, 0, 0.75);
}
80 changes: 80 additions & 0 deletions launchpad/static/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
body {
background: #fafafa;
color: #333333;
margin-top: 5rem;
}

h1, h2, h3, h4, h5, h6 {
color: #444444;
}

.bg-steel {
background-color: #5f788a;
}

.site-header .navbar-nav .nav-link {
color: #cbd5db;
}

.site-header .navbar-nav .nav-link:hover {
color: #ffffff;
}

.site-header .navbar-nav .nav-link.active {
font-weight: 500;
}

.content-section {
background: #ffffff;
padding: 10px 20px;
border: 1px solid #dddddd;
border-radius: 3px;
margin-bottom: 20px;
}

.article-title {
color: #444444;
}

a.article-title:hover {
color: #428bca;
text-decoration: none;
}

.article-content {
white-space: pre-line;
}

.article-img {
height: 65px;
width: 65px;
margin-right: 16px;
}

.article-metadata {
padding-bottom: 1px;
margin-bottom: 4px;
border-bottom: 1px solid #e3e3e3
}

.article-metadata a:hover {
color: #333;
text-decoration: none;
}

.article-svg {
width: 25px;
height: 25px;
vertical-align: middle;
}

.account-img {
height: 125px;
width: 125px;
margin-right: 20px;
margin-bottom: 16px;
}

.account-heading {
font-size: 2.5rem;
}
4 changes: 4 additions & 0 deletions launchpad/templates/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "layout.html" %}
{% block content %}
<h1>About Page</h1>
{% endblock content%}
15 changes: 15 additions & 0 deletions launchpad/templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "layout.html" %}
{% block content %}
{% for post in posts %}
<article class="media content-section">
<div class="media-body">
<div class="article-metadata">
<a class="mr-2" href="#">{{ post.author }}</a>
<small class="text-muted">{{ post.date_posted }}</small>
</div>
<h2><a class="article-title" href="#">{{ post.title }}</a></h2>
<p class="article-content">{{ post.content }}</p>
</div>
</article>
{% endfor %}
{% endblock content%}
Loading